Getting the other objects from the built-in array. C#
Is there is a way to get the other objects from an array, rather than a specific object from an array.
public Transform[] ItemSlots;
public int Key = 1;
What I am trying to do is change the colour of each "ItemSlots[]", to grey, when "Key" is a certain value, this does work, but what I would like to do is change the "ItemSlots[]" back to it's original colour when the "Key" value changes, if there is a way.
Please let me know if you need more information.
Answer by Dave-Carlile · Aug 27, 2015 at 02:48 PM
You can use a loop to do something with each item...
for (int i = 0; i < ItemSlots.Length; i++)
{
// use the i loop variable as the index
Transform item = ItemSlots[i];
// TODO : do what you want with item
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612001640im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to see if a string in a string array is equal to a normal string in C#? 1 Answer
Json to array of objects C# 1 Answer
Array index is out of range? 4 Answers
How to play all the animations array inside animation component 0 Answers
How to get all children of a Gameobject with a certain component 2 Answers