少年修仙传客户端基础资源
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
 
public class AnimationCurvePopupMenu
{
    private static AnimationCurve s_ClipBoardAnimationCurve;
 
    public static void Show(Rect popupRect, AnimationCurve animationCurve, SerializedProperty property)
    {
        if (GUI.Button(popupRect, GUIContent.none, "ShurikenDropdown"))
        {
            GUIContent content = new GUIContent("Copy");
            GUIContent content2 = new GUIContent("Paste");
            GUIContent content3 = new GUIContent("Clear");
            GenericMenu genericMenu = new GenericMenu();
 
            if (property != null)
            {
                genericMenu.AddItem(content, false, AnimationCurveCallbackCopy, property);
                genericMenu.AddItem(content2, false, AnimationCurveCallbackPaste, property);
                genericMenu.AddItem(content3, false, AnimationCurveCallbackClear, property);
            }
            else
            {
                genericMenu.AddItem(content, false, AnimationCurveCallback2Copy, animationCurve);
                genericMenu.AddItem(content2, false, AnimationCurveCallback2Paste, animationCurve);
                genericMenu.AddItem(content3, false, AnimationCurveCallback2Clear, animationCurve);
            }
 
            if (!HasClipBoardAnimationCurve())
            {
                genericMenu.AddDisabledItem(content2);
            }
            genericMenu.DropDown(popupRect);
            Event.current.Use();
        }
    }
 
    /// <summary>
    /// 清除检视器界面的曲线缓存,才能刷新新的值
    /// </summary>
    public static void AnimationCurvePreviewCacheClearCache()
    {
        Assembly assembly = Assembly.GetAssembly(typeof(ReorderableList));
        Type type = assembly.GetType("UnityEditorInternal.AnimationCurvePreviewCache");
        MethodInfo clearCache = type.GetMethod("ClearCache", BindingFlags.Static | BindingFlags.Public);
        if (clearCache != null)
        {
            clearCache.Invoke(null, null);
        }
    }
 
    private static bool HasClipBoardAnimationCurve()
    {
        return s_ClipBoardAnimationCurve != null;
    }
 
    private static void AnimationCurveCallbackCopy(object obj)
    {
        SerializedProperty property = (SerializedProperty)obj;
        s_ClipBoardAnimationCurve = property.animationCurveValue;
    }
 
    private static void AnimationCurveCallbackPaste(object obj)
    {
        if (s_ClipBoardAnimationCurve == null)
        {
            return;
        }
        SerializedProperty property = (SerializedProperty)obj;
        property.serializedObject.Update();
        property.animationCurveValue = s_ClipBoardAnimationCurve;
        property.serializedObject.ApplyModifiedProperties();
    }
 
    private static void AnimationCurveCallbackClear(object obj)
    {
        SerializedProperty property = (SerializedProperty)obj;
        property.serializedObject.Update();
        property.animationCurveValue = new AnimationCurve();
        property.serializedObject.ApplyModifiedProperties();
    }
 
    private static void AnimationCurveCallback2Copy(object obj)
    {
        AnimationCurve animationCurve = (AnimationCurve)obj;
        s_ClipBoardAnimationCurve = animationCurve;
    }
 
    private static void AnimationCurveCallback2Paste(object obj)
    {
        if (s_ClipBoardAnimationCurve == null)
        {
            return;
        }
        AnimationCurve animationCurve = (AnimationCurve)obj;
        animationCurve.keys = s_ClipBoardAnimationCurve.keys;
        animationCurve.postWrapMode = s_ClipBoardAnimationCurve.postWrapMode;
        animationCurve.preWrapMode = s_ClipBoardAnimationCurve.preWrapMode;
        AnimationCurvePreviewCacheClearCache();
    }
 
    private static void AnimationCurveCallback2Clear(object obj)
    {
        AnimationCurve animationCurve = (AnimationCurve)obj;
        if (animationCurve != null)
        {
            for (int i = animationCurve.length - 1; i >= 0; i--)
            {
                animationCurve.RemoveKey(i);
            }
            AnimationCurvePreviewCacheClearCache();
        }
    }
}