Help with my enumpopup.

Got this code in my normal script

public class Info : MonoBehaviour {
public enum Category {Asteroid, Galaxy, Planet, Satellite, Star} // My list.
public Category category;} // This creates my Popup in my normal inspector.

In my custom inspector I have this.

Info myTarget = (Info)target;
myTarget.Category = (int)(MyEnumType)EditorGUILayout.EnumPopup("Category:", (MyEnumType)Enum.GetValues(typeof(MyEnumType)).GetValue(myTarget.Category));

I tried to convert someones answer to mine, what goes into MyEnumType, for me its just an enum, what about (int) is that for the index or should it be something else? I believe the rest I have correct.

Can someone please help me fix this.

myTarget.category = (Category)EditorGUILayout.EnumPopup(“Category”,myTarget.category);

If someone explained it correctly I would of not have to search the web for 4 days, it was quite annoying. But this code worked that I finally translated. No site seemed to have had an answer, and none worked for me. Here I show how it should be.

First part is this (Info Script). Move the enum before class

public enum Category {Asteroid,Galaxy,Planet,Satellite,Star}
public class Info : MonoBehaviour {
public Category category;} // This creates my Popup in my normal inspector.

Second part is this. (Custom Editor Script)

using UnityEditor;
	
	[CustomEditor(typeof(Info))]
	public class InfoEditor : Editor	
{
	public override void OnInspectorGUI()
	{
		Info myTarget = (Info)target;
		myTarget.category = (Category)EditorGUILayout.EnumPopup("Category",myTarget.category);
		
	}}

Easy as that, I seen answers that did’t work with tons of more code and it didn’t work. :frowning: Maybe not compatible with Unity 4.3.