Search code examples
c#unity-game-engineunity-editor

UnityEvent Loses Its Custom Inspector When Serialized in a class as a property


so i have an array of Serializable classes, each with its own array of Serializable classes each of those has a UnityEvent.

class a : ScriptableObject
{
    entry[] entries
}

[Serializable]
class entry
{
    option[] Options
}

[Serializable]
class option
{
    string name;
    UnityEvent action;
}

the inspector of action

as opposed to the normal inspector view

(example of normal inspector)


Solution

  • You can't serialize a UnityEvent. You need to create a custom class for this, like this: https://answers.unity.com/questions/1275147/can-you-force-unity-to-serialize-a-unityevent-in-t.html