[CustomView]

Attribute allows defining custom drawing logic for a field via callback methods.

Parameters

Parameter Name
Arguments
Description

OnInitialization

void OnInitialization(SerializedProperty property, GUIContent label)

Called once when element view initialization.

OnGUI

void OnGUI(Rect position, SerializedProperty property, GUIContent label)

Called for drawing element.

GetHeight

float GetHeight(SerializedProperty property, GUIContent label)

Called for calculation element height.

Examples

using UnityEngine;
using RenownedGames.Apex;

public class CustomViewExample : MonoBehaviour
{
    [CustomView(OnGUI = "DrawMyField", GetHeight = "GetMyFieldHeight")]
    public string myField;

    private void DrawMyField(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.LabelField(position, label.text, "Custom Draw: " + property.stringValue);
    }

    private float GetMyFieldHeight(SerializedProperty property, GUIContent label)
    {
        return EditorGUIUtility.singleLineHeight;
    }
}

Last updated