Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<GameObject> list = new List<GameObject>();
- public int Index;
- public void FillList()
- {
- list.Add(whateverman); //Repeat as needed to fill your list
- }
- public void Cycle()
- {
- //Increment index
- Index++;
- if (Index == list.Count)
- {
- Index = 0;
- }
- //Perform the cycling.
- //For each in the list of objects...
- for(int i = 0; i < list.Count; i++)
- {
- //Check if they're active
- if (GameObject.active)
- {
- //If it isn't the object you seek disable it.
- if (i != Index)
- {
- GameObject.SetActive(false);
- }
- }
- else //If it's inactive...
- {
- //If it's the object you seek, enable it.
- if (i == Index)
- {
- GameObject.SetActive(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement