-
-
Save kirillrybin/5159778 to your computer and use it in GitHub Desktop.
C#/Unity3D – Shuffling an Arrayvia http://mrmoss.net/2013/cunity3d-shuffling-an-array/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Shuffle<T>(T[] obj) | |
{ | |
for (var i = 0; i < obj.Length; i++) | |
{ | |
var temp = obj[i]; | |
var obj_index = Random.Range(0, obj.Length); | |
obj[i] = obj[obj_index]; | |
obj[obj_index] = temp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment