Advertisement
Guest User

Untitled

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