- Home /
Question by
NutellaDaddy · Jun 12, 2014 at 05:16 AM ·
enumeditorguilayoutenumpopup
Type cast to a enum?
I keep on trying to do this editor extension of enum popup yet I keep on getting this error.
Cannot implicitly convert type `System.Enum' to `Item.Rarity'. An explicit conversion exists (are you missing a cast?).
How do I cast to an enum? I'll show you the script that causes this error.
Item.Rarity newRarity = Item.Rarity.None
newRarity = EditorGUILayout.EnumPopup ("Rarity: ", newRarity);
*NOTE: This is just a sample of the script
Comment
Best Answer
Answer by rutter · Jun 12, 2014 at 05:20 AM
Depending on scope, either:
newRarity = (Rarity)EditorGUILayout.EnumPopup ("Rarity: ", newRarity);
Or possibly:
newRarity = (Item.Rarity)EditorGUILayout.EnumPopup ("Rarity: ", newRarity);
The ()
parens and type in front are an explicit cast.