Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: sunny-becks on January 22, 2018, 02:52:19 AM
-
Hi, i am new to ngui. I want jump to the next Scene on Button Press. It works, but it is not very flexible.
public void OnClick ()
{
SceneManager.LoadScene (1);
}
How can i have a public int that i can change on the Button it self? The public int is not shown in Inspector like in Unitys Ui system.
I want to have something like this or a better way to organize things. Any ideas? Thanks for your time
public int changeScene;
// Use this for initialization
public void OnClick (){
SceneManager.LoadScene (changeScene);
}
}
-
Use the existing Event system. Attach a UIEventTrigger script to your button in the inspector. Add your script and method with its one parameter in the OnPress event. You pass an object to the parameter and select a property from it. I use a super simple script that just has a public int attached for things like level selection, and I pass that as a parameter in the UIEventTrigger parameter.
So I have two scripts on a level selection button, UI_Number that just has a public int, and UIEventTrigger that passes this int value to the script.