Hello,
I work with Unity 2019. I’m coding a MonoBehaviour class where there is an UnityEvent public field. And I want to create an EditorWindow for that script.
Others fields are correctly displayed. But I don’t know how to display the UnityEvent field in the EditorWindow. Even with a private variable declared in the EditorWindow, how do you show it?
Thanks
EditorGUI.PropertyField and EditorGUILayout.PropertyField should show a UnityEvent field with its’ custom drawer.
2 Likes
Thanks for your reply. I tried and this message appeared in console :
cannot convert from 'UnityEngine.Events.UnityEvent' to 'UnityEditor.SerializedProperty'
I made a mistake : the event is declared not in the MonoBehaviour class directly but in a another class, and this last one is instancied as a public field.
So I found the solution with SerializedObject(target)
and later with FindPropertyRelative()
.
Thank you
1 Like