- Home /
Changing Textures for a List of Objects
I have a list of objects stored and I want to reset them all through the list. Each of their textures change OnTrigger... and I want to reset them as a whole through the list. How would I call that? I figured a Foreach would be in use, but I dont know the line of code to retrieve the list and reset each member.
public class BlockControl : MonoBehaviour
{
public static Texture2D emptyBlock;
private GameObject[] brickBlockArray;
private GameObject[] questBlockArray;
public static List<GameObject> brickBlockList;
public static List<GameObject> questBlockList;
private int count;
void Start()
{
brickBlockArray = new GameObject[count];
brickBlockList = new List<GameObject>();
foreach(GameObject blockType in brickBlockArray = GameObject.FindGameObjectsWithTag("BrickBlock"))
{
brickBlockList.Add(blockType);
}
questBlockArray = new GameObject[count];
questBlockList = new List<GameObject>();
foreach(GameObject blockType in questBlockArray = GameObject.FindGameObjectsWithTag("QuestionBlock"))
{
questBlockList.Add(blockType);
}
}
public static void ResetBlocks()
{
//Reset here...
}
}
Comment
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Problem with getting resources and adding to list. (c#) 1 Answer
Can I use IENumerable.Repeat in Unity? 0 Answers
Check List<> for 'Item' 1 Answer
C# List tutorials & required code 1 Answer