Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question I made a Play button and when you open it it opens many buttons.

Discussion in 'Getting Started' started by BrunoValdeolmillos, May 13, 2024.

  1. BrunoValdeolmillos

    BrunoValdeolmillos

    Joined:
    Dec 2, 2023
    Posts:
    11
    Hello, good morning, I'm watching a tutorial and I programmed a function to the play button, I guess the error is due to the assets I downloaded. How can I solve it? Thank you.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine.SceneManagement;
    4. using UnityEngine;
    5.  
    6.  
    7. public class MainMenu : MonoBehaviour
    8. {
    9.   public void PLayGame()
    10.     {
    11.  
    12.         SceneManager.LoadSceneAsync(1);
    13.  
    14.     }
    15.  
    16. }
     
  2. influjensbahr

    influjensbahr

    Joined:
    Aug 31, 2015
    Posts:
    42
    Hi! Your play button is programmed so that it loads another scene - in this case, the scene with number 1 in the build settings. It looks like that's not the scene you would like it to load. You can check your build settings for a list of the scenes that are added there (the window screenshotted here) and you'll probably see a scene with number 1 listed there.

    Add the scene that you want to load to that list via drag and drop and change the number in your code to the correct number.
     
    BrunoValdeolmillos likes this.
  3. BrunoValdeolmillos

    BrunoValdeolmillos

    Joined:
    Dec 2, 2023
    Posts:
    11
    I don't have scene 1 yet, someone else has it.
    Thanks anyway, although I don't understand why I load those buttons by default, in any case I should have loaded nothing or no object