Quantcast
Channel: Questions in topic: "class instance"
Viewing all articles
Browse latest Browse all 131

Merging multiple array's from a specific class without manually targeting them

$
0
0
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 buttons; void Start() { buttons = new List(); 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 !

Viewing all articles
Browse latest Browse all 131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>