I am making *part* of my GUI through Unity, because there are just some things that I need it to do that ORK's GUI system does not have yet. I am working on my Map menu, which has five Unity buttons on the bottom to teleport to the five available zones in the game world. I need these buttons to load a new scene and spawn the player at one of the spawn points set up in the scene.
Basically I need it to do the equivalent of this node structure:
But I need that functionality inside my buttons: if(GUILayout.Button("First Zone",GUILayout.Width(Screen.width*.2f))){
}
I've searched through the API looking for key words, but I'm having trouble figuring out what methods I need to use to accomplish this task. Any help would be greatly appreciated.
SceneChanger changer = new GameObject().AddComponent<SceneChanger>(); changer.target = new SceneTarget[] {new SceneTarget(string sceneName, int spawnID)}; changer.StartEvent(null);
Post edited by gamingislove on
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
For those who may reference this thread looking for the same answer I was: make changer a class variable and initiate it in the Start method. Initiating in the OnGUI method creates countless GameObjects with SceneChanger components :) And then you can use the same changer for all your scene changes.
SceneChanger changer = new GameObject().AddComponent<SceneChanger>();
changer.target = new SceneTarget[] {new SceneTarget(string sceneName, int spawnID)};
changer.StartEvent(null);
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
For those who may reference this thread looking for the same answer I was: make changer a class variable and initiate it in the Start method. Initiating in the OnGUI method creates countless GameObjects with SceneChanger components :) And then you can use the same changer for all your scene changes.
Dave