Last active
March 24, 2021 07:45
-
-
Save BenjaminKobjolke/9950ec26066aebd7a1803deb12973efc to your computer and use it in GitHub Desktop.
Cast enum #unity
This file contains hidden or 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
int numWeapons = System.Enum.GetValues(typeof(WeaponType).Length; | |
// Cast weapon to int to do math on it | |
int wt = (int)weaponType; | |
wt++; | |
if( wt == numWeapons) wt = 0; | |
weaponType = (WeaponType) wt; |
This file contains hidden or 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
int numWeapons = System.Enum.GetValues(typeof(WeaponType).Length; | |
// Cast weapon to int to do math on it | |
int wt = (int)weaponType; | |
wt++; | |
if( wt == numWeapons) wt = 0; | |
weaponType = (WeaponType) wt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment