how can i access list of sprites in my code ??
i have 42 sprites, and i want them to access in my code. to select random 21 of them. how can i add them in a list or array? i want to color them red and to other sprites green . this is not working folder is named MAPS and sprites are tagged as country any idea to access them ??
Sprite[] countries = Resources.LoadAll<Sprite>("MAPS");
sr = GetComponent<SpriteRenderer>();
names = new string[countries.Length];
for (int i = 0; i < names.Length; i++)
{
names[i] = countries[i].name;
//0 = red
//1 = green
if (UnityEngine.Random.Range(0, 2) == 0)
{
this.GetComponent<SpriteRenderer>().color = Color.red;
}
else
{
this.GetComponent<SpriteRenderer>().color = Color.green;
}
}
Comment
Your answer
Follow this Question
Related Questions
how can i deploy 2 colors on 42 sprites randomly? 0 Answers
Random colors? 0 Answers
How can i detect/check color of sprites ? 0 Answers
Shift a Sprite's color palette? 0 Answers
How to generate a random color? 5 Answers