素人Unity練習帳
2D迷路ゲームを作る
さらに
-------goalScr.cs---------
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class goalScr : MonoBehaviour {
void Start () {
}
void Update () {
}
void OnCollisionEnter(Collision other)
{
Debug.Log("ゴール");
GameObject.DestroyObject(gameObject);//自分が消える
SceneManager.LoadScene("Clear");
}
}
-------goalScr.cs---------
として
File>BuildSettingsをおして

Scene In Build の項目に
mainとClearのシーンをドラッグして持っていく

一番初めに表示させるシーンを上にする。
試してみると、うまくいく


これを行わないと、ゴールに着いた時
Clearというシーンがわからなくて
エラーになる。
さらに
-------goalScr.cs---------
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class goalScr : MonoBehaviour {
void Start () {
}
void Update () {
}
void OnCollisionEnter(Collision other)
{
Debug.Log("ゴール");
GameObject.DestroyObject(gameObject);//自分が消える
SceneManager.LoadScene("Clear");
}
}
-------goalScr.cs---------
として
File>BuildSettingsをおして

Scene In Build の項目に
mainとClearのシーンをドラッグして持っていく

一番初めに表示させるシーンを上にする。
試してみると、うまくいく


これを行わないと、ゴールに着いた時
Clearというシーンがわからなくて
エラーになる。

Reon Viewin