EditorGUILayout.EnumPopup in another script

Hello all I come with a great request for oyu, I make a item system, and I need your help for a little problem, in my ItemDatabaseManager class I have a enum:

public enum TypeOfWeapon
    	{
    		baton,
    		hache1M,
    		hache2M,
    		epee1M,
    		epee2M,
    		masse1M,
    		masse2M,
    		distance,
    		bouclier,
    	}
    
    public TypeOfWeapon currentWeaponTypeToCreate = TypeOfWeapon.baton;

and in my ItemManagerInspector class I want make a EnumPopup for modify the type of my weapon.

how to use the public enum in my other class?

Thank.

for manage your public field from another class, you can use:

[CustomEditor(typeof(ItemDatabaseManager))]
public class ItemManagerInspector : Editor {
    public override void OnInspectorGUI()
    {
        ItemDatabaseManager item = (ItemDatabaseManager)target;
    
    TypeOfWeapon itemType = item.itemType;
            itemType = (TypeOfWeapon)EditorGUILayout.EnumPopup("Item type", itemType);
            item.itemType = itemType;

   }

}

Salut Isador34! Je suis passé par le même problème…

So to display an EnumPopup on your custom inspector, put this line of code in your OnInspectorGUI() function:

//Look for the Enum ("ItemDatabaseManager") and the var you want to change/display ("currentWeaponTypeToCreate")
ItemDatabaseManager.currentWeaponTypeToCreate = (ItemDatabaseManager)EditorGUILayout.EnumPopup("The Weapon: ", ItemDatabaseManager.currentWeaponTypeToCreate);

And finally, add “static” before currentWeaponTypeToCreate in your ItemDatabaseManager class:

public static TypeOfWeapon currentWeaponTypeToCreate = TypeOfWeapon.baton;

Hope this helps!
Math