0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Unity] Sceneの切り替え方法

Last updated at Posted at 2020-12-31

Sceneの切り替えをざっくりですがまとめました。
自分用メモです。

①まず、SampleSceneとNextSceneを作る。

②sampleSceneに移動し、UIからButtonを作る。
(positionX 0; Y 0; で真ん中にくる)

③project部分で右クリックしcreate→C#ScriptでScriptの作成。

④下記のコードを追加する。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

↓ここから下の部分を追記
using UnityEngine.SceneManagement;

public class Test : MonoBehaviour
{
public void MoveScene()
{
SceneManager.LoadScene("NextScene");
}
}

⑤ヒエラルキーにCreateEmptyでからのオブジェクトを作成。

⑥作成済のC#Scriptをドラッグ。

⑦ButtonのインスペクタのOnClick部分の+を押し、
GameObjectをドラッグ。
右の選択部分からTest→Test.MoveSceneを選択する。

⑧ビルドセッティングを開き、NewSceneを追加する。

動作確認する。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?