前提・実現したいこと
ドットインストールの新unity入門#25にて、ボタンのonclickの機能を使い、gameoversceneからmainsceneに移動するようにしようとしていました。
発生している問題・エラーメッセージ
ボタンを押したときにエラーが表示される。 Scene 'MainScene' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene(String) ButtonScript:ReplayGame() (at Assets/Scripts/ButtonScript.cs:10) UnityEngine.EventSystems.EventSystem:Update()
該当のソースコード
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.SceneManagement; 5 6public class ButtonScript : MonoBehaviour 7{ 8 public void ReplayGame() 9 { 10 SceneManager.LoadScene("MainScene"); 11 } 12 13 // Start is called before the first frame update 14 void Start() 15 { 16 17 } 18 19 // Update is called once per frame 20 void Update() 21 { 22 23 } 24} 25
試したこと
file>build settingsで、Scenes/Main scene 0,
Scenes/GameOver scene 1
となるようにしました。
gameoversceneのbuttonのon Click()の欄を
Runtime Only ,ButtonScript.ReplayGame,
Button(Butt...←表示枠外
になっています。
補足情報(FW/ツールのバージョンなど)
windows8.1
visual stadio 2017
Unity 2019.1.0f2 (64-bit)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/02 08:11