Skip to content

Instantly share code, notes, and snippets.

@kirillrybin
Last active April 12, 2016 11:55
Show Gist options
  • Save kirillrybin/5159778 to your computer and use it in GitHub Desktop.
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/
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