Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved How to make play screen that goes to scene2

Discussion in '2D' started by cyclSunity, Aug 30, 2020.

  1. cyclSunity

    cyclSunity

    Joined:
    Jun 10, 2020
    Posts:
    123
    Hi. So making a game, need to know how to make main menu. HOL UP though. I tried Brackeys video. Didn't work. Sooooo yuh. Plz help.
     
  2. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Hi @cyclSunity,

    You should create both, menu and gameplay scenes first.

    Once you have both, you need to include them on the Build Settings, having the menu as the first scene.

    Also, you need to assign the loading of the gameplay scene to the respective button of the main menu.

    My recommendation for you is to go to the Unity Official tutorials and find there one that is similar to the type of game that you're trying to create and learn how to do it first.

    You can find those tutorials here: https://learn.unity.com/


    Happy learning!
     
  3. cyclSunity

    cyclSunity

    Joined:
    Jun 10, 2020
    Posts:
    123
    I have done that before (the Brackeys video told me to) and it doesn't work! I even put
    using UnityEngine.SceneManagement;
    or that one
    using
    tag. Sooooo...,
     
  4. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Can you share with us a screenshot of your build settings and the content of your script?
     
  5. cyclSunity

    cyclSunity

    Joined:
    Jun 10, 2020
    Posts:
    123
    Sure the script is
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class PlayButton : MonoBehaviour {
    7.      void onClick() {
    8.          SceneManager.LoadScene(1)
    9. }
    10.  
    11. }
    And in build settings I have scene "Main" (index of 0) and scene "SecondScene" (index of 1)
     
  6. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Thank you for the additional info.

    I'm not sure how are you "wiring" your interface, but there are some considerations that you have to be aware of:

    First of all, `MonoBehaviour` doesn't have any function called "onClick", so if you expect your code to be called automatically when the user is clicking on the related GameObject, you could use instead `OnMouseUp` on `OnMouseDown` for example.

    You can have more information about MonoBehaviour and their functions here: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html

    However, more likely is not the best way to create your menu.

    My recommendation on that matter for you is to use Unity's built-in UI components.

    You can have an overview of how the UI basic components work here: https://learn.unity.com/tutorial/ui-components


    Good luck with it!
     
  7. cyclSunity

    cyclSunity

    Joined:
    Jun 10, 2020
    Posts:
    123
    No, in inspector, I click play button and click on click, and connect it to the function.
     
  8. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Would you mind sharing a screenshot of how your `Inspector` window looks like, regarding the connection with the `onClick` function?


    Thank you!
     
  9. cyclSunity

    cyclSunity

    Joined:
    Jun 10, 2020
    Posts:
    123
    Sometime later, yeah
     
  10. cyclSunity

    cyclSunity

    Joined:
    Jun 10, 2020
    Posts:
    123
    Nvm I found out by my self, thx for all support tho!!!
     
    DiegoDePalacio likes this.
  11. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    506
    Glad you found it!

    I'm happy to help you ;)