Hi, I’m working on a quizz game as a little project for my coworkers. I’m not an expert in coding.
Here is my issue : I was getting tired of always having to rewrite text in my levels button and make it all centered and nice. So I made this little simple script to name the buttons and made sure everything was alright with my prefabs.
using UnityEngine;
public class LevelSelectorUI : MonoBehaviour
{
[SerializeField] private LevelButton buttonPrefab = null;
private void Start() {
for (int i = 0; i < LevelManager.instance.AllLevels.Length; i++) {
var lb = Instantiate(buttonPrefab, transform);
lb.Setup(i+1, LevelManager.instance.AllLevels[i]);
}
}
}
Now my issue is that I’m planning on adding “Bonus levels” in my game. So for example after level 4, you would have a “hidden” level 4.5.
I was thinking of making a script that instead of adding +1, goes through a list of “names and numbers” that I would just simply edit. Every new instance of the button would have the next name or number. But I’m a complete beginner at coding and can’t seem to wrap my head around it…
For example the list go go as follow :
1
2
3
4
4.5
5
5.5
6
Boss
etc…
Any help is appreciated