Unity在Inspecter面板中显示事件

 

public class MyPlanet : MonoBehaviour
{
        [Serializable]
        public class ZoomLevelChangedEvent : UnityEvent<int> { }
        public ZoomLevelChangedEvent zoomLevelChangedEvent;
}

如果要在自定义Editor中显示

override public void OnInspectorGUI()
{
    serializedObject.Update();

    EditorGUILayout.BeginVertical();
    SerializedProperty sprop = serializedObject.FindProperty("zoomLevelChangedEvent");
    EditorGUILayout.PropertyField(sprop, new GUIContent("zoomLevelChangedEvent Object"));
    EditorGUILayout.EndVertical();

	serializedObject.ApplyModifiedProperties();
}

猜你喜欢

转载自blog.csdn.net/zouxin_88/article/details/121949884
今日推荐