タイトルの通りですが、
Start()でSceneManager.LoadSceneを使って読み込んだ読込中用シーンを
Update()の1フレーム目でSceneManager.UnloadSceneAsyncを使ってアンロードしようとしています。
が、アンロードされずヒエラルキーにはシーンが残ったままになってしまいます。使い方が間違っているでしょうか?
c#
1 public bool isFirstUpdate = false; 2 3 void Start () { 4 // NowLoaingシーン読み込み 5 SceneManager.LoadScene ("now_loading", LoadSceneMode.Additive); 6 7 // ワールドマップの初期設定 8 //initWorldMap(); 9 10 // プレイヤーの初期設定 11 //initPlayer(); 12 } 13 14 void Update () { 15 if (!isFirstUpdate) { 16 isFirstUpdate = true; 17 // NowLoaingシーン破棄 18 //SceneManager.UnloadSceneAsync("now_loading"); // これだと破棄されなかったので下でループしてみる 19 20 //現在読み込まれているシーン数だけループ 21 for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount ; i++) { 22 //読み込まれているシーンを取得し、その名前をログに表示 23 Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); 24 string sceneName = scene.name; 25 Log.d("sceneName", sceneName); 26 if ("now_loading".Equals(sceneName)) { 27 Debug.Log ("if now_loading true"); 28 // NowLoaingシーン破棄 29 SceneManager.UnloadSceneAsync(scene); 30 Debug.Log ("after UnloadSceneAsync"); // ここまで到達していることを確認 31 } 32 } 33 } 34 }
◆環境
Unity2017 3.1f1
Windows 10
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/22 13:22
2018/04/22 14:51