- Home /
Question by
MarcelGar6 · Mar 19, 2017 at 05:03 PM ·
buttonsevents
Take string from OnClick event and throw into variable.
Hey guys! I've searched a lot without success and I need a hand with this silly question. I've created buttons to select the level and on each button there's a OnClick event with a LoadLevel(string currentLevel).
I've tried something like this but it didn't work:
currentLevel = gameObject.GetComponent<Button>().onClick.ToString();
How do I get this string "currentLevel" from the event and throw it into a variable in my script? Thanks in advance!
level-1.png
(8.6 kB)
level-2.png
(5.4 kB)
Comment
Answer by MarcelGar6 · Mar 18, 2017 at 04:06 PM
Forget it! I've found a way:
void Start(){
currentLevel = SceneManager.GetActiveScene().name;
}
I'll let the question here for other people's future research!