How to create a list in a specific order of one script that is used in different gameobjects?
Hi, so in a recent project that i have been working on, i need to change the material of an object when i receive a certain id from serial port. For that i used a script where i have a public boolean that i activate in the events of the serial port and that script is attached to several child objects that i need to change material when received a certain id by the server. Im doing that by creating a list with every script with the same name and changing the value of the boolean for the list index that i send via server, but the list index weren't matching the order of the gameobjects i had in the scene.
List test= new List(); // Start is called before the first frame update public override void Awake() { base.Awake(); foreach(ChangeColor t in GameObject.FindObjectsOfType(typeof(ChangeColor))) { test.Add(t); } }
Is there any way to create the list following a certain order, and only looking in the children of a container?
Your answer
Follow this Question
Related Questions
list misbehaving in bubble shooter 0 Answers
Issue where Fading out Game Object causes screen to blank and then reload with gameobject gone 0 Answers
Objects, GameObjects, Lists, and lists of GameObjects with Objects, oh my! 2 Answers
Death Countdown Area 0 Answers
Need a script to hide the player 1 Answer