Skip to content

Instantly share code, notes, and snippets.

@farukcan
Last active January 30, 2022 16:34
Show Gist options
  • Save farukcan/50efa59b8044a99ddc031e8bf2bdbe19 to your computer and use it in GitHub Desktop.
Save farukcan/50efa59b8044a99ddc031e8bf2bdbe19 to your computer and use it in GitHub Desktop.
C# Get All Enum Values
public class Example : MonoBehaviour
{
private enum TetrisPiece
{
Line, Square, T, J, L, S, Z
}
RandomBag<TetrisPiece> pieceBag;
void Awake()
{
// Get an array with each value of TetrisPiece
TetrisPiece[] tetrisPieceArray = (TetrisPiece[]) Enum.GetValues(typeof (TetrisPiece));
Debug.Log(TetrisPiece);
// Example output:
// Line, Square, T, J, L, S, Z
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment