• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
4
Question by bhayward_incrowd · Jan 25, 2016 at 03:23 PM · errorsceneloadscene-loadingbuild settings

Scene IS added to build settings: "Scene couldn't be loaded because it has not been added to the build settings"

Hi everyone,

I am getting the error "Scene couldn't be loaded because it has not been added to the build settings" despite the fact that the scene IS in the build settings, and ticked.

My code to load the scene is as follows:

 void genericLoadScene(string sceneName, List<string> parameters)
 {
     SceneManager.LoadScene (sceneName+"");
 }

As you can see by the presence of sceneName+"", I am definitely passing it a string, not a variable name. The error occurs with specifically this scene. All other scenes work fine.

![Image of Build Settings][1]

I have checked the string that I am passing in to ensure it is correct many multiple times. What am I doing wrong, please?

  • have tried reordering the scenes* [1]: /storage/temp/62590-screen-shot-2016-01-25-at-152122.png

screen-shot-2016-01-25-at-152122.png (44.1 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ShadyProductions · Jan 25, 2016 at 03:37 PM -1
Share

try loading it by number ins$$anonymous$$d of the name.

avatar image bhayward_incrowd ShadyProductions · Jan 25, 2016 at 03:42 PM 0
Share

It loads by number absolutely fine. Then I can compare the name string that I am passing in with the name of the correctly loaded level, and they are equal... Which still begs the question: Why won't it load with the name only?

avatar image bhayward_incrowd · Jan 25, 2016 at 03:50 PM 0
Share

If I change my genericLoadScene method to

     void genericLoadScene(string sceneName, List<string> parameters)
     {
         Debug.Log ("Loading Scene "+sceneName);
         Scene$$anonymous$$anager.LoadScene (14);
         Debug.Log ("Scene Loaded "+Scene$$anonymous$$anager.GetActiveScene ().name + "");
 
         if (sceneName == Scene$$anonymous$$anager.GetActiveScene ().name) {
             Debug.Log ("Scene names WERE equal!!!");
         } else {
             Debug.Log ("It turns out "+sceneName+" is not equal to "+Scene$$anonymous$$anager.GetActiveScene ().name);
         }
 
     }

it prints out "It turns out S11 PlayerBooking is not equal to S11 PlayerBooking"

7 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by bhayward_incrowd · Jan 25, 2016 at 04:40 PM

After having iterated through all characters in the two strings, I have found the answer! Unfortunately, my scene had a space in it; although, it wasn't a 'proper' space, as in unicode 32. In fact, it was unicode 160; a non-break space.

Note for the future: Don't use spaces!!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jason-H · Jul 05, 2016 at 08:55 AM 0
Share

I would have suggested copying and pasting the string from the .unity asset to the class just to make sure they're the same.

avatar image Manticore_standardcombo · May 09, 2017 at 09:10 PM 0
Share

I was having the same issue and this answer is what pointed me in the right direction. I used the String.Trim() to eliminate the wild symbols from beginning and end of the scene names.

avatar image
26

Answer by OneCept-Games · Oct 26, 2017 at 08:39 AM

TIP: If it is not about whitespaces, then it might be that you have move your scene to another folder in the hierarchy. Build Settings seems to adapt this new folder, but you actually have to re-drag your scenes into the Build Settings, else you will have this error also. Just a tip if you happen to meet this issue again later when you are sure there are no spaces and spelling issue.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image wenderRondonia · Oct 31, 2017 at 01:55 PM 0
Share

Yeah, my case was solved by dragging the scene again to build settings, I moved it to another folder and probably lost reference or something!

avatar image theolagendijk · Dec 25, 2017 at 10:22 PM 0
Share

Thanks OneCept-Games, I encountered this issue after reorganising my projects folder structure.

avatar image Guessmyname · Jan 01, 2018 at 05:00 PM 0
Share

Yup, just had exactly this issue.

Annoyingly, it turns out that the moved scenes will work perfectly fine in builds but won't be found correctly in the editor, which lead to a lot of confused frustration.

Definitely an editor bug.

avatar image MrDude · Jan 15, 2018 at 10:04 AM 0
Share

I reorganised my folder structure and ran into this problem. I checked to see if the path names matched in File->BuildSettings and all were okay... So I took another route...

See, I actually have my scene names as an enum and then select which scene to load by setting the scene in the inspector and saying, for instance,

 Scene$$anonymous$$anager.LoadSceneAsync(next_scene.ToString());

so now, ins$$anonymous$$d, I said

 Scene$$anonymous$$anager.LoadSceneAsync( (int)next_scene);

This should also work just fine since my enum contains the scene names in th same order as the BuildSettings since the BuildSettings contain them in the order that I want them to be loaded... Turns out that with 3 scenes in BuildSettings, trying to call LoadSceneAsync with an int value of 1 still resulted in the scene not being present in build settings.

Does this constitute a bug, I wonder?

p.s. Forgot to mention... clearing BuildSettings and dragging the scenes in again fixed the numeric scene loading also

avatar image
0

Answer by MADiFold · Jan 05, 2019 at 09:36 AM

Actually...(I just ran into it after getting my own Collaborated project from one system to another), it has to do with the fact that the project doesn't seem to like the items already in the list in the Buildscreen. Easiest is to remove all scenes and add them again. No need to change the code. The project will then be able to find the items again.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Dljcali82 · Feb 17, 2019 at 09:58 AM

One issue I've learned is that when you take the name as a string from another object.. if the object is a texture file (maybe others as well), it may associate that to the name. I learned this because I manually added the name of the file and it worked, yet when I try it with the string, the debug.log description has (UnityEngine.Texture2d) attached to the string output. Still trying to find the right solution for that, but I'm sure it won't be long before I do. Good luck!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by HarrisonWeber · Mar 01, 2019 at 01:44 AM

This Helped Me! Thank You!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

57 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

After reloading the scene twice one script doesn't work. 0 Answers

SceneManager.LoadScene is crashing or freezing for Android Devices 3 Answers

Only half of work/wall spawping after die and restart game,Why load after die only half scene? 1 Answer

Get current scene number 3 Answers

Scene Editor Problem @username 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges