Open lorenblue opened 9 months ago
Unity 2022.3.12, and it shouldn't be improper setup on my end because everything works fine in the same class as long as it's a public field and not a prop.
Hi! I don't think Unity serializes properties and so MarkupAttributes do not work on them.
It should be a field to work properly. Though it doesn't have to be public, private/protected [SerializeFiled] marked ones work as well.
Unity most definitely serializes the backing fields though. The serialization aspect of the snippet I added above works, and I use it all the time. Cheers!
I see. Either it did not do it before or I was misguided. Whichever it is, I only check for attributes the FieldInfo for each SerializedProperty, so the attributes on properties won't register. Relevant code is here: https://github.com/gasgiant/Markup-Attributes/blob/main/Assets/MarkupAttributes/Core/Editor/EditorLayoutDataBuilder.cs
Or, if I understand the syntax correctly, the attributes are applied to the backing field. In this case it won't have the same name as the SerializedProperty, so GetField would return null.
Gotcha. Do you think this could be something you support? All good if not, I was just hoping to switch away from Naughty Attributes as yours seems to handle nesting way better.
I think I can do this relatively easily, if the name of the underlying property can be relied on. I'll let you know about the outcome.
Sounds good, cheers!
Sgining up for an update for the solution.
Hey! Hopefully I am wrong, but the following doesn't seem to produce any desired results for me:
[field: SerializeField] [field: Box("Group")] public bool TestProp { get; private set; }