Merging multiple array's from a specific class without manually targeting them
Hello, I got into Unity really hardcore, around 8-12 hours a day of continues learning, I just can't stop.
the problem is that I'm trying to merge multiple arrays into one.
I know about System.linq, and about Lists too,
the thing is, that I want to be able to select all of the buttons without manually adding them in-code,
so whenever a new array of buttons is being added, declaring this array/list will add it too.
the class it-self is within a class for customization options, and I can't search them by type as they start in-active in scene, and some spawn in after the scene loads.
I thought about selecting every GameObject within this specific class,
or running a 'for loop' for the length of the class' arrays, and then the arrays themselves for targeting each GameObject, but I couldn't find a way to do so.
This is my code:
[System.Serializable]
public class Buttons
{
public GameObject[] mainMenuButtons, levelMenuButtons;
[HideInInspector]
public GameObject[] levelButtons;
[HideInInspector]
public List<GameObject> buttons;
void Start()
{
buttons = new List<GameObject>();
buttons.AddRange(mainMenuButtons);
buttons.AddRange(levelMenuButtons);
buttons.AddRange(levelButtons);
}
};
Pretty simple code, what's inside the 'Start' function is a temporary solution, and if there isn't any other way it will stay permanent.
So.. is there a way to automate that?
thank you for patience !
I just noticed that 'Start' won't work in this class as this is not a '$$anonymous$$onoBehaviour' type class. But it has nothing to do with the matter, so you can just ignore that :)