Understanding SerializedPropertyType?

882 Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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.

1
On

The concrete problem is not clear. To receive help I would try to narrow down the problem along with a code snippet with your attempt and where you're stuck at. In case its of any help regarding "I don't know what a couple of the types refer to, and the documentation does not explain very well what I need to know about the type", what you need to know is that unity handles the serialization itself to show the fields in the inspector, let you program the editor UI etc, so you need to check Script Serialization to check what classes are serializable in unity.

Very probably for your case you need to check how to custom serialize your class. The first step is how to program a simple serializable class inheriting from the Editor class, and from there maybe move on to more complex cases.

Check also maybe if there is already something done to be used or inspire you. this might be useful.