├── .gitignore ├── AnimationCurvePopupMenu ├── .gitignore ├── Assets │ ├── Editor.meta │ ├── Editor │ │ ├── AnimationCurveDrawer.cs │ │ ├── AnimationCurveDrawer.cs.meta │ │ ├── AnimationCurveGUI.cs │ │ ├── AnimationCurveGUI.cs.meta │ │ ├── AnimationCurvePopupMenu.cs │ │ ├── AnimationCurvePopupMenu.cs.meta │ │ ├── TestCurveEditor.cs │ │ └── TestCurveEditor.cs.meta │ ├── Test.unity │ ├── Test.unity.meta │ ├── TestCurve.cs │ └── TestCurve.cs.meta └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityAdsSettings.asset │ └── UnityConnectSettings.asset ├── README.md └── Screenshots ├── screenshot_clear.png ├── screenshot_copy.png └── screenshot_paste.png /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | 21 | 22 | # Unity3D generated meta files 23 | *.pidb.meta 24 | 25 | # Unity3D Generated File On Crash Reports 26 | sysinfo.txt 27 | 28 | # Builds 29 | *.apk 30 | *.unitypackage 31 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/.gitignore: -------------------------------------------------------------------------------- 1 | /Library/ 2 | /Temp/ 3 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e121d2db1b5f6a46a3a29ebffb3a894 3 | folderAsset: yes 4 | timeCreated: 1467200556 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/AnimationCurveDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | [CustomPropertyDrawer(typeof(AnimationCurve))] 5 | public class AnimationCurveDrawer : PropertyDrawer 6 | { 7 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 8 | { 9 | AnimationCurveGUI.OnGUI(position, property, label); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/AnimationCurveDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51fc08f728922d94b804b10d0dddf893 3 | timeCreated: 1467200556 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/AnimationCurveGUI.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | public class AnimationCurveGUI 5 | { 6 | private static Rect SubtractPopupWidth(Rect position) 7 | { 8 | position.width -= 18f; 9 | return position; 10 | } 11 | 12 | private static Rect GetPopupRect(Rect position) 13 | { 14 | position.xMin = position.xMax - 13f; 15 | return position; 16 | } 17 | 18 | #region EditorGUILayout 19 | public static AnimationCurve CurveField(AnimationCurve value, params GUILayoutOption[] options) 20 | { 21 | Rect position = EditorGUILayout.GetControlRect(false, 16f, EditorStyles.colorField, options); 22 | return CurveField(position, value); 23 | } 24 | 25 | public static AnimationCurve CurveField(string label, AnimationCurve value, params GUILayoutOption[] options) 26 | { 27 | Rect position = EditorGUILayout.GetControlRect(true, 16f, EditorStyles.colorField, options); 28 | return CurveField(position, label, value); 29 | } 30 | 31 | public static AnimationCurve CurveField(GUIContent label, AnimationCurve value, params GUILayoutOption[] options) 32 | { 33 | Rect position = EditorGUILayout.GetControlRect(true, 16f, EditorStyles.colorField, options); 34 | return CurveField(position, label, value); 35 | } 36 | #endregion 37 | 38 | #region EditorGUI 39 | public static AnimationCurve CurveField(Rect position, AnimationCurve value) 40 | { 41 | AnimationCurve animationCurve = EditorGUI.CurveField(SubtractPopupWidth(position), value); 42 | AnimationCurvePopupMenu.Show(GetPopupRect(position), animationCurve, null); 43 | return animationCurve; 44 | } 45 | 46 | public static AnimationCurve CurveField(Rect position, string label, AnimationCurve value) 47 | { 48 | return CurveField(position, new GUIContent(label), value); 49 | } 50 | 51 | public static AnimationCurve CurveField(Rect position, GUIContent label, AnimationCurve value) 52 | { 53 | AnimationCurve animationCurve = EditorGUI.CurveField(SubtractPopupWidth(position), label, value); 54 | AnimationCurvePopupMenu.Show(GetPopupRect(position), animationCurve, null); 55 | return animationCurve; 56 | } 57 | #endregion 58 | 59 | /// 60 | /// 默认属性字段的绘制,也会为PropertyField自动绘制 61 | /// 62 | /// 63 | /// 64 | /// 65 | public static void OnGUI(Rect position, SerializedProperty property, GUIContent label) 66 | { 67 | label = EditorGUI.BeginProperty(position, label, property); 68 | EditorGUI.CurveField(EditorGUI.PrefixLabel(SubtractPopupWidth(position), label), property, Color.green, default(Rect)); 69 | AnimationCurvePopupMenu.Show(GetPopupRect(position), null, property); 70 | EditorGUI.EndProperty(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/AnimationCurveGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 677915183234a3c40bff720f40d27e22 3 | timeCreated: 1467200556 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/AnimationCurvePopupMenu.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using UnityEngine; 4 | using UnityEditor; 5 | using UnityEditorInternal; 6 | 7 | public class AnimationCurvePopupMenu 8 | { 9 | private static AnimationCurve s_ClipBoardAnimationCurve; 10 | 11 | public static void Show(Rect popupRect, AnimationCurve animationCurve, SerializedProperty property) 12 | { 13 | if (GUI.Button(popupRect, GUIContent.none, "ShurikenDropdown")) 14 | { 15 | GUIContent content = new GUIContent("Copy"); 16 | GUIContent content2 = new GUIContent("Paste"); 17 | GUIContent content3 = new GUIContent("Clear"); 18 | GenericMenu genericMenu = new GenericMenu(); 19 | 20 | if (property != null) 21 | { 22 | genericMenu.AddItem(content, false, AnimationCurveCallbackCopy, property); 23 | genericMenu.AddItem(content2, false, AnimationCurveCallbackPaste, property); 24 | genericMenu.AddItem(content3, false, AnimationCurveCallbackClear, property); 25 | } 26 | else 27 | { 28 | genericMenu.AddItem(content, false, AnimationCurveCallback2Copy, animationCurve); 29 | genericMenu.AddItem(content2, false, AnimationCurveCallback2Paste, animationCurve); 30 | genericMenu.AddItem(content3, false, AnimationCurveCallback2Clear, animationCurve); 31 | } 32 | 33 | if (!HasClipBoardAnimationCurve()) 34 | { 35 | genericMenu.AddDisabledItem(content2); 36 | } 37 | genericMenu.DropDown(popupRect); 38 | Event.current.Use(); 39 | } 40 | } 41 | 42 | /// 43 | /// 清除检视器界面的曲线缓存,才能刷新新的值 44 | /// 45 | public static void AnimationCurvePreviewCacheClearCache() 46 | { 47 | Assembly assembly = Assembly.GetAssembly(typeof(ReorderableList)); 48 | Type type = assembly.GetType("UnityEditorInternal.AnimationCurvePreviewCache"); 49 | MethodInfo clearCache = type.GetMethod("ClearCache", BindingFlags.Static | BindingFlags.Public); 50 | if (clearCache != null) 51 | { 52 | clearCache.Invoke(null, null); 53 | } 54 | } 55 | 56 | private static bool HasClipBoardAnimationCurve() 57 | { 58 | return s_ClipBoardAnimationCurve != null; 59 | } 60 | 61 | private static void AnimationCurveCallbackCopy(object obj) 62 | { 63 | SerializedProperty property = (SerializedProperty)obj; 64 | s_ClipBoardAnimationCurve = property.animationCurveValue; 65 | } 66 | 67 | private static void AnimationCurveCallbackPaste(object obj) 68 | { 69 | if (s_ClipBoardAnimationCurve == null) 70 | { 71 | return; 72 | } 73 | SerializedProperty property = (SerializedProperty)obj; 74 | property.serializedObject.Update(); 75 | property.animationCurveValue = s_ClipBoardAnimationCurve; 76 | property.serializedObject.ApplyModifiedProperties(); 77 | } 78 | 79 | private static void AnimationCurveCallbackClear(object obj) 80 | { 81 | SerializedProperty property = (SerializedProperty)obj; 82 | property.serializedObject.Update(); 83 | property.animationCurveValue = new AnimationCurve(); 84 | property.serializedObject.ApplyModifiedProperties(); 85 | } 86 | 87 | private static void AnimationCurveCallback2Copy(object obj) 88 | { 89 | AnimationCurve animationCurve = (AnimationCurve)obj; 90 | s_ClipBoardAnimationCurve = animationCurve; 91 | } 92 | 93 | private static void AnimationCurveCallback2Paste(object obj) 94 | { 95 | if (s_ClipBoardAnimationCurve == null) 96 | { 97 | return; 98 | } 99 | AnimationCurve animationCurve = (AnimationCurve)obj; 100 | animationCurve.keys = s_ClipBoardAnimationCurve.keys; 101 | animationCurve.postWrapMode = s_ClipBoardAnimationCurve.postWrapMode; 102 | animationCurve.preWrapMode = s_ClipBoardAnimationCurve.preWrapMode; 103 | AnimationCurvePreviewCacheClearCache(); 104 | } 105 | 106 | private static void AnimationCurveCallback2Clear(object obj) 107 | { 108 | AnimationCurve animationCurve = (AnimationCurve)obj; 109 | if (animationCurve != null) 110 | { 111 | for (int i = animationCurve.length - 1; i >= 0; i--) 112 | { 113 | animationCurve.RemoveKey(i); 114 | } 115 | AnimationCurvePreviewCacheClearCache(); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/AnimationCurvePopupMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a489e6d3b58df6a46bc47348469a40e5 3 | timeCreated: 1467200556 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/TestCurveEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | [CustomEditor(typeof(TestCurve))] 5 | public class TestCurveEditor : Editor 6 | { 7 | SerializedProperty curveProp; 8 | SerializedProperty curveProp2; 9 | private AnimationCurve m_TestAnimCurve = new AnimationCurve(); 10 | private AnimationCurve m_TestAnimCurve2 = new AnimationCurve(); 11 | 12 | void OnEnable() 13 | { 14 | curveProp = serializedObject.FindProperty("curve"); 15 | curveProp2 = serializedObject.FindProperty("curve2"); 16 | } 17 | 18 | public override void OnInspectorGUI() 19 | { 20 | serializedObject.Update(); 21 | 22 | EditorGUILayout.PropertyField(curveProp); 23 | EditorGUILayout.PropertyField(curveProp2, new GUIContent("Curve2 Object")); 24 | 25 | m_TestAnimCurve = AnimationCurveGUI.CurveField("扩展曲线", m_TestAnimCurve); 26 | m_TestAnimCurve2 = EditorGUILayout.CurveField("默认曲线", m_TestAnimCurve2); 27 | 28 | //EditorGUILayout.TextField("abc"); 29 | 30 | serializedObject.ApplyModifiedProperties(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Editor/TestCurveEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60ff6bafc5d32db4b87abf5dc2159d9d 3 | timeCreated: 1467200556 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Test.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/Assets/Test.unity -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da67d09a4f151594ca7fb2dd4e2e85b7 3 | timeCreated: 1467200688 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/TestCurve.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class TestCurve : MonoBehaviour 5 | { 6 | public AnimationCurve curve; // for preview 7 | public AnimationCurve curve2; // for preview 8 | } 9 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/Assets/TestCurve.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 079fcfcf76d5a204f9af86781d95edac 3 | timeCreated: 1467200556 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.4p5 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /AnimationCurvePopupMenu/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/AnimationCurvePopupMenu/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity AnimationCurvePopupMenu 2 | Unity 曲线编辑扩展菜单功能 3 | 4 | # 原因 5 | 默认的 AnimationCurve 字段曲线编辑,不支持复制粘贴到另一个 AnimationCurve 字段,亦不支持关键帧的清空。所以扩展 AnimationCurve 的绘制,在右侧添加下拉菜单,以扩展功能。 6 | 7 | # 功能 8 | * 复制曲线 9 | * 粘贴曲线 10 | * 清空曲线 11 | 12 | # 截图 13 | 点击右侧下拉按钮,点击 Copy 复制: 14 | 15 | ![](https://github.com/akof1314/UnityAnimationCurvePopupMenu/raw/master/Screenshots/screenshot_copy.png) 16 | 17 | 在另一个曲线,右侧菜单点击 Paste 粘贴: 18 | 19 | ![](https://github.com/akof1314/UnityAnimationCurvePopupMenu/raw/master/Screenshots/screenshot_paste.png) 20 | 21 | 清空曲线的关键帧值,点击 Clear 清空: 22 | 23 | ![](https://github.com/akof1314/UnityAnimationCurvePopupMenu/raw/master/Screenshots/screenshot_clear.png) 24 | 25 | # 使用说明 26 | 代码放进工程里面,对于默认的脚本,会自动调用扩展的曲线绘制方式: 27 | 默认的脚本类似: 28 | ```csharp 29 | public class TestCurve : MonoBehaviour 30 | { 31 | public AnimationCurve curve; 32 | } 33 | ``` 34 | 高级方式,要对默认脚本进行自定义绘制的话,创建 Editor 类。接着,对于属性值,调用 Unity 自带的接口 `EditorGUILayout.PropertyField` 即可。对于非属性值,可通过 AnimationCurveGUI 接口来替换 EditorGUILayout 和 EditorGUI 来绘制曲线: 35 | ```csharp 36 | using UnityEngine; 37 | using UnityEditor; 38 | 39 | [CustomEditor(typeof(TestCurve))] 40 | public class TestCurveEditor : Editor 41 | { 42 | private SerializedProperty curveProp; 43 | private AnimationCurve m_TestAnimCurve = new AnimationCurve(); 44 | 45 | void OnEnable() 46 | { 47 | curveProp = serializedObject.FindProperty("curve"); 48 | } 49 | 50 | public override void OnInspectorGUI() 51 | { 52 | serializedObject.Update(); 53 | 54 | EditorGUILayout.PropertyField(curveProp); 55 | m_TestAnimCurve = AnimationCurveGUI.CurveField("扩展曲线", m_TestAnimCurve); 56 | 57 | serializedObject.ApplyModifiedProperties(); 58 | } 59 | } 60 | ``` 61 | -------------------------------------------------------------------------------- /Screenshots/screenshot_clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/Screenshots/screenshot_clear.png -------------------------------------------------------------------------------- /Screenshots/screenshot_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/Screenshots/screenshot_copy.png -------------------------------------------------------------------------------- /Screenshots/screenshot_paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akof1314/UnityAnimationCurvePopupMenu/b8af7c9d54f566e2e6f2854c28df329034664680/Screenshots/screenshot_paste.png --------------------------------------------------------------------------------