TextAlignmentOptions is bugged if set via inspector (Unity 2020.3.2f1) (850478)

Hello,

I want to set the TextAlignementOptions for TextMeshPro in my inspector and assign it during runtime.
However I get a nullreference when I test it and the Alignemnt always defaults to kind of centered but not really.

    public TMP_Text text;
    public TextAlignmentOptions options = TextAlignmentOptions.Baseline;

    // Start is called before the first frame update
    void Start()
    {
        text.alignment = options;
    }

I’ve debugged the code and options is always zero (0). This shouldn’t be possible since the enum starts with TopLeft (257), so I’m stumped right now.
If I assign the options in code like text.alignment = TextAlignmentOptions.TopLeft; it works, however I want to set it via inspector so this is not a solution.

I am using Unity 2020.3.2f1 and TextMeshPro 3.0.6.

Apparently the problem was that the default value of an enum is not the first entry of it but 0 (like I already mentioned before), so if the enum in question doesn’t have a valid entry for 0 it will create errors. I didn’t know that this was a default c# behaviour and assumed it would automatically be set to the first enum entry or be handled by the TMPro Editor code.

I would’ve noticed this sooner but in the inspector the displayed values were all correct, it was only causing problems during runtime.

I fixed it now by assigning my desired default value if the value of the enum is zero, however it still seems like quite the big oversight that this isn’t handled by the TMPro editor code.