Hi everyone,
I am building a game in which I have come across a situation where:
I have 150 Buttons in a scroll view.
I want to load different Levels on clicks of different Buttons.
For Instance;
On click of a button at 0 index => Level 1 will be loaded
On click of a button at 1 index => Level 2 will be loaded
and so on…
Solution I tried
- Naming buttons in Hierarchy like this
Level Btns
- Btn 1
- Btn 2
- Btn 3
so on…
- Added script to each button that raises events with their respective names in parameters
- On event receive I split name on basis of space
- Parse index 1 to an integer to load the respective level
My Question:
Is this is the best way of doing it or is there any better way?
Thanks