LoginSignup
1
2

More than 3 years have passed since last update.

Unity Sceneの遷移について(備忘録)

Posted at

UnityのSceneの遷移について

UnityのSceneの遷移の方法を復習したから、それを忘れないようにするために備忘録を付けておく。
まず練習用にSceneを二つ用意して、それらのシーンに空のGameObjectを追加する。
そして以下のスクリプトをそのGameObjectにアタッチすることによってSceneの遷移を行うことが出来る。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;//Sceneを変更するために使う

public class red : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        if (Input.GetMouseButtonDown(0))//マウスのボタンが押されたら
        {
            SceneManager.LoadScene("green");//greenというSceneに移動する
        }
    }
}

 注意点

using UnityEngine.SceneManagement;//Sceneを変更するために使う

ここを忘れないようにすること

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2