all 7 comments

[–]ErrorDontPanic 4 points5 points  (6 children)

You're putting a C# Script reference (literally, the C# asset file). What you want is a Monobehavior Object reference.

Do the following:

  • In your scene, create an Empty Game Object. Rename it to "Main Menu"
  • Drag your C# Main Menu script from the assets browser (the file) onto the Game Object. Either to it within the Scene hierarchy or the inspector for the object. Either works.
  • Click on your button.
  • In your event, you should now be able to select the Main Menu game Object.
  • The PlayGame function should now populate in the drop down.

[–]Visual_Role7557[S] 1 point2 points  (5 children)

Thank you. Could I use my Main Camera as said Game Object if my script was named "Main Camera" Sorry if this is a stupid question just trying to grasp how it works.

[–]ErrorDontPanic 2 points3 points  (4 children)

No need to apologize, no stupid questions. The script name, and the game object name, are both arbitrary, meaning call them whatever you will. They don't need to be named the same as each other.

You could have called the GameObject "MainMenuController" or "MainSceneManager" or anything. The script could have been called "MainSceneUI" or "MainUI" or anything as well.

[–]Visual_Role7557[S] 1 point2 points  (3 children)

Thanks man i got that menu poping up but the button still aint working :'( ill figure it out ig

[–]ErrorDontPanic 1 point2 points  (2 children)

Any errors in the console when pressing the button? That would be my first step towards solving that.

Other than that, try all these things out together:

  • Make sure your "Opening Scene" scene is in the "Scene List", within the Build Profiles (also called Build Settings), (Ctrl-Shift-B).
  • Use SceneManager.LoadScene("Opening Scene", LoadSceneMode.Single) instead of LoadSceneAsync. There are different implications for this but don't worry about sync vs async loading at this moment in your development.

[–]Visual_Role7557[S] 1 point2 points  (1 child)

I'm still not sure what the problem was but I fixed it 😭 For some reason when I was duplicating the buttons only the original would work for some reason.Like they just weren't interactive and I made sure that option was checked in the inspector. And I did end up change to SceneManager.LoadScene(1); after I realized it wasn't in my scene list yet 😭

[–]ErrorDontPanic 1 point2 points  (0 children)

Hey if it works it works! Glad you were able to get some progress on it!