Virtual Methods
OnInitialize
Description
Called once when initializing PropertyView.
Very useful for make some initializations of properties and get view attribute.
void OnInitialize(SerializedProperty property, ViewAttribute viewAttribute, GUIContent label)
{
// Some initialization...
}
Parameters
Parameter | Description |
---|---|
property | Serialized property with ViewAttribute. |
viewAttribute | ViewAttribute of serialized property. |
label | Label of serialized property. |
Example
[ViewTarget(typeof(ExampleAttribute))]
public class ExampleView : PropertyView
{
private ExampleAttribute exampleAttribute;
// Called once when initializing PropertyView.
public override void OnInitialize(SerializedProperty property, ViewAttribute viewAttribute, GUIContent label)
{
// Getting ExampleAttribute attribute from field.
exampleAttribute = viewAttribute as ExampleAttribute;
// Some other initializations here...
}
}
OnGUI
Description
Called for rendering and handling GUI events.
void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// Property GUI here...
}
Parameters
Parameter | Description |
---|---|
position | Position of the serialized property. |
property | Serialized property with ViewAttribute. |
label | Label of serialized property. |
Example
[ViewTarget(typeof(ExampleAttribute))]
public class ExampleView : PropertyView
{
// Called for rendering and handling GUI events.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.Label(position, "Custom property view");
}
}
GetPropertyHeight
Description
Return height which needed to draw property.
float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
// Return height of property.
}
Parameters
Parameter | Description |
---|---|
property | Serialized property with ViewAttribute. |
label | Label of serialized property. |
Example
[ViewTarget(typeof(ExampleAttribute))]
public class ExampleView : PropertyView
{
// Return height which needed to draw property.
public virtual float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return 20;
}
}