Search code examples
unity-game-engineunity-editor

Understanding SerializedPropertyType?


I am creating a generic class that requires me to check the SerializedPropertyType of it's fields, and for the most part I know what each value of SerializedPropertyType means, but there are two values that I do not, and the API Documentation provides no useable information, the two values in question are SerializedPropertyType.ManagedReference, and SerializedPropertyType.FixedBufferSize.

The page for ManagedReference states "Managed reference property." as the description and for FixedBufferSize it states "Fixed buffer size property.", neither of which tell me what those types are used for.


Solution

  • Unity's documentation can be annoying when finding specific doc pages. For the managed property, here is a useful doc page. And in case Unity decides to remove that page, it reads

    Represents a property that references an object that does not derive from UnityEngine.Object.

    This type is for fields that have the SerializeReference attribute, otherwise the object is stored inline (SerializedPropertyType.Generic).

    As for FixedBufferSize, I could only find moderately helpful documentation and it is for SerializedProperty.fixedBufferSize, not SerializedPropertyType. I believe the fixedBufferSize is referring to a fixed buffer struct in C#, which you can read about here. The size is just a quick lookup for the physical size of the buffer - how many elements are contained in this buffer.