Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Unity loop around an array

// Wraping around an array or list
currentIndex = (currentIndex + 1) % myList.Count; // Forward
currentIndex = (myList.Count + currentIndex - 1) % myList.Count; //Backward
 
PREVIOUS NEXT
Tagged: #Unity #loop #array
ADD COMMENT
Topic
Name
8+8 =