How do i draw a field of the Type UnityEvent in a Custom Inspector like in the Default Inspector
Can’t get a hold on any call to draw it or property drawer?
Can anyone help?
How do i draw a field of the Type UnityEvent in a Custom Inspector like in the Default Inspector
Can’t get a hold on any call to draw it or property drawer?
Can anyone help?
Simply use “EditorGUIUtility.LookLikeControls();” before drawing property field
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
UI_TOGGLE toggle = (UI_TOGGLE)target;
SerializedProperty onCheck = serializedObject.FindProperty("onCheck"); // <-- UnityEvent
EditorGUIUtility.LookLikeControls();
EditorGUILayout.PropertyField(onCheck);
if(GUI.changed)
{
serializedObject.ApplyModifiedProperties();
}
}
For anyone else necroing this thread, this is no longer necessary. Just use EditorGUILayout.PropertyField
, and the event will be drawn (unity 2019.3.3f1)
It says that EditorGUIUtility.LookLikeControls(); is obsolete, I still can’t get my unity event to work.