unity-game-engineserializableunity-editorscriptable-object

Serializable object is looking weird in the inspector


So I have this small class called StoryTrigger:

namespace VisualNovelScripting
{
    [System.Serializable]
    public class StoryTrigger
    {
        [SerializeField] public string triggerName;
        public bool value;

        public StoryTrigger(string name, bool value = false)
        {
            
            this.triggerName = name;
            this.value = value;
        }
    }
}

And I want to make a ScriptableObject with a list of StoryTrigger objects that could add, remove and edit elements right on the unity inspector.

I assumed that if the StoryTrigger had the [System.Serializable] modified it should work. And It kind of works but looks like this on the inspector:

enter image description here

I want to know if there's something I am doing wrong or something I could do better so it doesn't look this weird on the inspector or if this is an issue on the unity editor.


Solution

  • I saw that when I add only 1 element to the StoryTriggers list it does look weird on the inspector like shown in the question.

    But when I add multiple elements it stops looking weird. So I can work with it.

    I assume this is a bug on the Unity Editor since the condition to the weird behavior is on the amount of elements on the list.

    EDIT:

    Soon after that, I realized that no matter how many elements I add to the list, the first one will always look weird when expanded (like shown in the question). Still, it is not something impossible to work with. I already sent a bug report to unity.