Is there a specified/documented set of steps that the Unity goes through when you click + on a List<>
item in the inspector?
For example, I have a serializable class that is within a List<>
. When I click +, it appends a new element to the list but it also initializes it to a copy of the final element in the list. I have tried setting values in the default constructor of that class, but these are obviously getting overwritten.
(As an aside, I’m also curious how the original wording “Element 0”, “Element 1”, etc. got overwritten with my
[SerializeField, HideInInspector] private string _serializedGuid
on its own without me saying “Hey this is my GUID, please show it!”. NB: I do set the value of a private Guid _id
based on _serializedGuid within OnAfterDeserialize()
)
The reason I’m asking this is because I want to override the process and initialize data myself the way I want. I’m sure OnValidate()
is relevant but I’m unclear when/where it gets called in the process.