少年修仙传客户端基础资源
dabaoji
2025-06-09 8ee0256378cbf5dbc9d76ed10b60b65a844ef4dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using UnityEngine;
using UnityEditor;
 
public class AnimationCurveGUI
{
    private static Rect SubtractPopupWidth(Rect position)
    {
        position.width -= 18f;
        return position;
    }
 
    private static Rect GetPopupRect(Rect position)
    {
        position.xMin = position.xMax - 13f;
        return position;
    }
 
    #region EditorGUILayout
    public static AnimationCurve CurveField(AnimationCurve value, params GUILayoutOption[] options)
    {
        Rect position = EditorGUILayout.GetControlRect(false, 16f, EditorStyles.colorField, options);
        return CurveField(position, value);
    }
 
    public static AnimationCurve CurveField(string label, AnimationCurve value, params GUILayoutOption[] options)
    {
        Rect position = EditorGUILayout.GetControlRect(true, 16f, EditorStyles.colorField, options);
        return CurveField(position, label, value);
    }
 
    public static AnimationCurve CurveField(GUIContent label, AnimationCurve value, params GUILayoutOption[] options)
    {
        Rect position = EditorGUILayout.GetControlRect(true, 16f, EditorStyles.colorField, options);
        return CurveField(position, label, value);
    }
    #endregion
 
    #region EditorGUI
    public static AnimationCurve CurveField(Rect position, AnimationCurve value)
    {
        AnimationCurve animationCurve = EditorGUI.CurveField(SubtractPopupWidth(position), value);
        AnimationCurvePopupMenu.Show(GetPopupRect(position), animationCurve, null);
        return animationCurve;
    }
 
    public static AnimationCurve CurveField(Rect position, string label, AnimationCurve value)
    {
        return CurveField(position, new GUIContent(label), value);
    }
 
    public static AnimationCurve CurveField(Rect position, GUIContent label, AnimationCurve value)
    {
        AnimationCurve animationCurve = EditorGUI.CurveField(SubtractPopupWidth(position), label, value);
        AnimationCurvePopupMenu.Show(GetPopupRect(position), animationCurve, null);
        return animationCurve;
    }
    #endregion
 
    /// <summary>
    /// 默认属性字段的绘制,也会为PropertyField自动绘制
    /// </summary>
    /// <param name="position"></param>
    /// <param name="property"></param>
    /// <param name="label"></param>
    public static void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        label = EditorGUI.BeginProperty(position, label, property);
        EditorGUI.CurveField(EditorGUI.PrefixLabel(SubtractPopupWidth(position), label), property, Color.green, default(Rect));
        AnimationCurvePopupMenu.Show(GetPopupRect(position), null, property);
        EditorGUI.EndProperty();
    }
}