Skip to content

Instantly share code, notes, and snippets.

@monsterbrain
Created May 17, 2017 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monsterbrain/bfe4098337381cb9a5f3d1591946b3d8 to your computer and use it in GitHub Desktop.
Save monsterbrain/bfe4098337381cb9a5f3d1591946b3d8 to your computer and use it in GitHub Desktop.
Shuffle Array in Unity Code Snippet Script
void reshuffle(string[] texts)
{
// Knuth shuffle algorithm :: courtesy of Wikipedia :)
for (int t = 0; t < texts.Length; t++ )
{
string tmp = texts[t];
int r = Random.Range(t, texts.Length);
texts[t] = texts[r];
texts[r] = tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment