How do I connect my main menu screen scene to go to another scene?
Sorry I'm a little new to Unity and stuff so I still am trying to figure things out.
I currently have a menu screen for this fighting game I'm making, I'm trying to make it so that if you click the button that says 1v1, it'll take you to a scene where you can choose your own character. How exactly do i do this? If it helps, im using the 2018 long term support version of unity.
Thanks :)
Answer by BradyIrv · Jun 06, 2019 at 12:16 AM
Make a script that will handle the button event onClick:
using UnityEngine.SceneManagement;
public void LoadAScene(string sceneName) {
SceneManager.LoadScene(sceneName);
}
Then you can set up the button in hierarchy by adding an OnClick method that will call this function. And as @Silentones mentioned, make sure to add your scenes in File > build settings.
For more information on Scene Loading: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
Answer by Silentones · Jun 06, 2019 at 05:33 AM
I think you also need to add the scenes in the build settings
You also need to be on the Scene that you want to add "" Add Open Scene""
File >> Build Settings >> Add Open scenes
and then write up the scenes that you want to load in after an event.
EX:
public void Death()
{
dead = true;
Destroy(gameObject, .5f);
Player.enabled = false;
SceneManager.LoadScene("MainMenu");
}
Your answer
Follow this Question
Related Questions
Is it possible to make a color wheel in a script? 0 Answers
Getting trouble in migrating the Unity IAP old version to new version of IAP in existing project 0 Answers
How can I get the player to face the direction it is going in a Unity 2D Game? 0 Answers
Unity 2D Build Error 0 Answers
LookAt in 2d is not working Again :/ 0 Answers