Using an enum inside of a scriptable Object - why don't I see it in the inspector?

Hi =)

I came across a curious thing and would like to understand why this happens.

I have a very simple script like this:

using UnityEngine;

[CreateAssetMenu]
public class Test : ScriptableObject
{
	public int id;
	public enum Category { green, red };
}

Now, if I create a new Test-Object (right click → Create new → Test), I can see its id-value, but not its enum field. I declared it as “public”, so… shouldn’t I be able to set its value inside the inspector?

Whenever I use enums on non-scriptable Objects, they work just fine and I can see them in the Inspector, too. Would love to get some help on this :slight_smile:

You don’t have any enum field. All you have there is a nested enum type declaration of name “Category”. If you want your Test class to have a field of that type, well you have to add a field:

 [CreateAssetMenu]
 public class Test : ScriptableObject
 {
     public int id;
     public Category category; // field
     public enum Category { green, red }; // nested type
 }

Though depending on how and where you want to use your Category type you may want to declare it outside the class

 public enum Category { green, red };
 
 [CreateAssetMenu]
 public class Test : ScriptableObject
 {
     public int id;
     public Category category;
 }