Wanzyee Studio

Extension methods for UnityEditor.SerializedProperty. More...

Static Public Member Functions

static void CheckValid (this SerializedProperty property)
 Check if the property, serializedObject, and targetObject, all exist, otherwise throw an exception. More...
 
static SerializedProperty GetParent (this SerializedProperty property)
 Get the parent UnityEditor.SerializedProperty contains this. More...
 
static string GetTooltip (this SerializedProperty property)
 Get the tooltip of the property, return string.Empty if none. More...
 
static void CheckArray (this SerializedProperty property)
 Check if the property is a valid array property. More...
 
static SerializedProperty Insert (this SerializedProperty property, int index=-1, bool copy=false)
 Insert an array element at the specified index and return it. More...
 
static void AddRange (this SerializedProperty property, IEnumerable< Object > collection)
 Add the source collection to the array property. More...
 

Detailed Description

Extension methods for UnityEditor.SerializedProperty.

Member Function Documentation

static void CheckValid ( this SerializedProperty  property)
static

Check if the property, serializedObject, and targetObject, all exist, otherwise throw an exception.

Parameters
propertyProperty.
static SerializedProperty GetParent ( this SerializedProperty  property)
static

Get the parent UnityEditor.SerializedProperty contains this.

Return null if this is a root within target object.

Parameters
propertyProperty.
Returns
The parent.
static string GetTooltip ( this SerializedProperty  property)
static

Get the tooltip of the property, return string.Empty if none.

The built-in SerializedProperty.tooltip never works with unknown reason. This uses EditorGUI.BeginProperty() to fetch the tooltip, must be called in OnGUI().

Parameters
propertyProperty.
Returns
The tooltip.
static void CheckArray ( this SerializedProperty  property)
static

Check if the property is a valid array property.

Parameters
propertyProperty.
static SerializedProperty Insert ( this SerializedProperty  property,
int  index = -1,
bool  copy = false 
)
static

Insert an array element at the specified index and return it.

Optional to copy values from the original element at the index, like the Unity's default behavior. Otherwise Leave all the values empty.

Parameters
propertyProperty.
indexIndex.
copyIf set to true copy.
Returns
Element property.
static void AddRange ( this SerializedProperty  property,
IEnumerable< Object >  collection 
)
static

Add the source collection to the array property.

Parameters
propertyProperty.
collectionCollection.