Created
May 17, 2017 11:14
-
-
Save monsterbrain/bfe4098337381cb9a5f3d1591946b3d8 to your computer and use it in GitHub Desktop.
Shuffle Array in Unity Code Snippet Script
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
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