// Animancer // https://kybernetik.com.au/animancer // Copyright 2022 Kybernetik // using UnityEngine; namespace Animancer { /************************************************************************************************************************/ /// An object that will be drawn by a . public interface IPolymorphic { } /************************************************************************************************************************/ /// An with a method. public interface IPolymorphicReset : IPolymorphic { /// Called when an instance of this type is created in a [] field. void Reset(); } /************************************************************************************************************************/ /// The attributed field will be drawn by a . public sealed class PolymorphicAttribute : PropertyAttribute { } /************************************************************************************************************************/ } #if UNITY_EDITOR namespace Animancer.Editor { using UnityEditor; /// [Editor-Only] /// A for and . /// [CustomPropertyDrawer(typeof(IPolymorphic), true)] [CustomPropertyDrawer(typeof(PolymorphicAttribute), true)] public class PolymorphicDrawer : PropertyDrawer { /************************************************************************************************************************/ /// public override float GetPropertyHeight(SerializedProperty property, GUIContent label) => EditorGUI.GetPropertyHeight(property, label, true); /************************************************************************************************************************/ /// public override void OnGUI(Rect area, SerializedProperty property, GUIContent label) { using (new TypeSelectionButton(area, property, true)) EditorGUI.PropertyField(area, property, label, true); } /************************************************************************************************************************/ } } #endif