unity3d - Instead of LoadLevel, how do i use SceneManager -


i super new in coding , couldn't find right answer on web. want change scene in game. i've had buttons etc. can't choose "menu" script on click function menus.

all answer welcome!

using unityengine; using unityengine.scenemanagement; using system.collections;  public class menu : monobehaviour { public void changescene(string scenename)     {         scenemanager.loadscene("scenename");     } } 

enter image description here

you can't plug in menu script left slot.

you have attache menu gameobject plug gameobject left slot.you able chose script , function send event on right.

the image below shows wrong way this(this how doing it):

enter image description here

the correct way it:

enter image description here

you can code:

public class menu : monobehaviour {     public button playbutton;      void start()     {         //add button event         playbutton.onclick.addlistener(() => buttoncallback(playbutton));     }     public void changescene(string scenename)     {         scenemanager.loadscene("scenename");     }      private void buttoncallback(button buttonpressed)     {         if (buttonpressed == playbutton)         {             changescene("myscene");         }     } } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -