Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. public List<GameObject> list = new List<GameObject>();
  2. public int Index;
  3.  
  4. public void FillList()
  5. {
  6.     list.Add(whateverman); //Repeat as needed to fill your list
  7. }
  8.  
  9. public void Cycle()
  10. {
  11.     //Increment index
  12.     Index++;
  13.  
  14.     if (Index == list.Count)
  15.     {  
  16.     Index = 0;
  17.     }
  18.  
  19.     //Perform the cycling.
  20.  
  21.     //For each in the list of objects...
  22.     for(int i = 0; i < list.Count; i++)
  23.     {
  24.         //Check if they're active
  25.         if (GameObject.active)
  26.         {
  27.             //If it isn't the object you seek disable it.
  28.             if (i != Index)
  29.             {
  30.                 GameObject.SetActive(false);
  31.             }
  32.         }
  33.         else //If it's inactive...
  34.         {
  35.             //If it's the object you seek, enable it.
  36.             if (i == Index)
  37.             {
  38.                 GameObject.SetActive(true);
  39.             }
  40.         }
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement