SceneManager.LoadScene(1); trolls me

Being me, I managed to stroll away from the course and ended up using “EditorSceneManager” functions to load my scenes, which worked fine, except you can’t do a final build with that.
When I finally realized that, I wanted to correct my doing but it just did not work out.

I followed the Course (this time :slight_smile: ), unity tells me :

Assets/Scripts/Rocket.cs(85,22): error CS0117: SceneManager' does not contain a definition forLoadScene’

Well, we did use Scenemanagement in the Blockbreaker at the Unity 1 course too, so I opened my files and compared.
They are identical. Same code, same version of Unity.
One works, one does not.
What is going on here?

image

Please send help :dizzy_face:

1 Like

You haven’t added a class called SceneManager by chance, have you?

Have you tried using

UnityEngine.SceneManagement.SceneManager.LoadScene( “Scenename”);

Arent the Scene names also classed as a string, so wouldn’t you always use quotation marks within the brackets as in (“1”)

although I could be wrong, excuse any ignorance I may be showing.

2 Likes

:thinking: :face_with_raised_eyebrow::scream::roll_eyes:

You, Sir, are my personal hero.
I may name my firstborn after you.
SceneManager seemed to be such a good name for my Method ^^

That is the solution indeed.

2 Likes

Hey no worries man, glad I could help :smiley:

Nice spot @Wadricks with the duplicate class name. :slight_smile:

Arent the Scene names also classed as a string, so wouldn’t you always use quotation marks within the brackets as in (“1”)

The SceneManager’s LoadScene method actually has an overloaded method which also allows an int value to be passed in, by doing so you can load methods via their buildIndex value as an alternative to by name.

@Hagyto - note you can just paste your code into your posts on our forum and then format it using the ` characters before and after the block of code (see link below). Screenshots are very useful however for displaying settings/issues in the Unity editor.


See also;

1 Like

I know (and did in other posts), thanks for the pointer.
I just wanted to make clear the comparison between the both projects next to each other in a visual easy to grasp way.
Thought that way it would be easiest to see my problem (one working vs, one not working but seemingly the same code) :slight_smile:

1 Like

No worries and it worked well :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms