Public method not accepting input from the inspector

As mentioned in the title, once I type a string in the code of LevelManager, whatever I write in the inspector will not replace what is written in code. That previously was not the case. Which leads me to think that either :

  1. there might be a glitch in Unity
  2. there is something I might have misplaced in code or the Unity UI

Given my track record thus far, I do believe that it is option 2. Attached below is an example of the problem:

The image shows the start scene, with the option button mapped so that it would take me to the options scene if pressed.

Below is the code from the LevelManager:

public void LoadScene (string sceneName)
		SceneManager.LoadScene ("02 Level_1");


As you can see, I have written 02 Level_1 in the sceneName string space.
Now if I press the options button it will take me to the 1st level scene, not the options scene.

I require your assistance please.
Thank you

Hi Uhadi,

In your code, you pass on a string called “02 Level_1” to the LoadScene method. Hence “02 Level_1” gets loaded instead of “01b Options”.

Please try the following:

public void LoadScene (string sceneName)
    SceneManager.LoadScene (sceneName);

Does that fix the issue?

1 Like

Hello Nina,
Thank yo for the reply. The issue unfortunately was not resolved. I instead get the following error message:

Unity seems to be registering the string I place as an actual scene that it has to have in the build settings, and not as a placeholder to be replaced with what I write in the inspector.
Not sure what exactly am I missing…

Thank you for you help

Hola uhadi,
You need to include your scenes in the build settings window. File > build Settings… Ben has shown this in the videos. Select your scenes and drop them in your build Setting window. if you already did then check your spelling does it match what you are passing into the load scene method? Rob’s suggestion might be helpful for you.

Hi Yusuf,

I hope all is well.

The error you are receiving could occur if you have the parameter sceneName with quotation marks, for example “sceneName”.

If you don’t have this speicifically with the LoadScene method as per Nina’s example above, trying adding a Debug.Log statement on the first line of that method and out put the sceneName parameter being passed in, perhaps the quotation marks are coming from a value in the Inspector?


public void LoadScene (string sceneName)
    Debug.Log("sceneName parameter : " + sceneName);

    SceneManager.LoadScene (sceneName);    // note no quotation marks

Hope this helps. :slight_smile:

Thank you Greg_Sherman for the input. I have added them to my build settings, but unfortunately the problem persists.


Hello Rob,
I think that solved it!
Thank you very much.

All the best,

1 Like

Looking back at your message Nina, i should’ve realized that there were no quotations. Apologies.

Thank you very much

1 Like

You’re welcome Yusuf :slight_smile:

Don’t worry, that happens to all of us. I’m glad you were able to fix it. :slight_smile:

1 Like

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

Privacy & Terms