6
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 1 year has passed since last update.

【Unity】シーン切り替えでエラー"Scene 'シーン名' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded."が発生する

Last updated at Posted at 2022-08-02

シーンの切り替えをするときに以下のエラーに遭遇した

Scene 'シーン名' 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...

ひとまず言われた通り直す

エラー文に以下ように指示されているので『File』→『Build Settings』で設定を行う

To add a scene to the build settings use the menu File->Build Settings...

『Build Settings』を開く

image.png

開くとこんな画面
image.png

使うシーンを追加する
Project-Scenesから使うシーンをBuild SettingsのScenes In Buildにドラック&ドロップ
image.png
追加したあとの画面
image.png

これで動くはずだが、私の環境ではまだ同じエラーが発生していた

LoadScene()の引数(シーン名)のtypoが原因だった

LoadSceneメソッドを使用してシーンの切り替えを行っていたが、引数のシーン名とAssets>Scenesに格納されているシーン名が一致していなかった

    public void OnStartButton()
    {
        SceneManager.LoadScene("シーン名");
    }

シーン名を一致させると期待通り動いた

参考

[Unity]LoadScene()でシーンが切り替わらない時の対処法

6
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
6
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?