Search Unity

How to Change scenes from Menu

Discussion in 'Scripting' started by Deleted User, Mar 12, 2021.

  1. Deleted User

    Deleted User

    Guest

    Hey all, not sure if this is the right forum for this but couldn't see any other ones. I've used the 'Unity Samples: UI' and using the Menu 3D scene template as my menu. Then I added some panel's for my game, and there's one for actually going into the game, I've tried ways to change scene's but not sure how to, I used
    Code (CSharp):
    1. public void ChangeMenuScene(string scenename)
    2.     {
    3.         SceneManager.LoadScene(scenename);
    4.     }
    but I'm not sure what functions need to be added, Could I get some assistance. Thanks in advance
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    The above code might be complete. Code is a tiny fraction of what needs to happen. Your UI and button responders have to be set up. Start with some tutorials on Unity buttons (or for whatever UnityEngine.UI object you are using)... there are plenty:

    Screen Shot 2021-03-12 at 7.23.36 AM.png
     
  3. Deleted User

    Deleted User

    Guest

    Thanks for the reply, I've already done somethng like this before, and have set it up as well before. But for some reason it isn't working and have doubled check everything
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    Well we know it works, so it's just a matter of debugging your setup.

    To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run?
    - what are the values of the variables involved? Are they initialized?

    Knowing this information will help you reason about the behavior you are seeing.
     
  5. Deleted User

    Deleted User

    Guest

    Thank you so much for your help, I just checked again and made the worst error, I didnt add it to the build settings!!
     
    Kurt-Dekker likes this.
  6. Deleted User

    Deleted User

    Guest

    Sorry to disturb again but I'd like to use different types of pics as the background, as well as the font etc. Where can I find these assets. I've tried the asset store as well as general map pics found on images but I use them in my Hierarchy. Any Ideas where I could find these assets, I'm making a FPS shooter game