duck

Unity returning a random enum example

Jul 7th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.20 KB | None | 0 0
  1. enum StarType { O, B, A, F, G, K, M }
  2.  
  3. public static StarType RandomStarType() {
  4.    
  5.     StarType[] allTypes = Enum.GetValues(typeof(MyEnum));
  6.  
  7.     return allTypes[ Random.Range(0, allTypes.Length) ];
  8.    
  9. }
Advertisement
Add Comment
Please, Sign In to add comment