-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAnimationChangeTool.cs
More file actions
119 lines (102 loc) · 3.46 KB
/
AnimationChangeTool.cs
File metadata and controls
119 lines (102 loc) · 3.46 KB
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
119
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class AnimationChangeTool : EditorWindow
{
private static List<AnimationClip> allAnimatinClips = new List<AnimationClip>();
private float addvalue;
//private static float curAniValue;
[MenuItem("Tools/AnimationChangeTool")]
static void ShowWindow()
{
var window = (AnimationChangeTool)GetWindow(typeof(AnimationChangeTool));
window.maxSize = new Vector2(200, 250);
window.Show();
//GetCurKeys();
}
void ClearAll()
{
allAnimatinClips.Clear();
}
private void GetAnimationClips()
{
var selAnimatins = Selection.objects;
foreach (var a in selAnimatins)
{
if (a.GetType() == typeof(AnimationClip))
{
allAnimatinClips.Add(a as AnimationClip);
}
}
}
//private static void GetCurKeys()
//{
// foreach (AnimationClip a in allAnimatinClips)
// {
// var bindigs = AnimationUtility.GetCurveBindings(a);
// var AnimationCurves = AnimationUtility.GetEditorCurve(a, bindigs[5]);
// var keys = AnimationCurves.keys;
// curAniValue = keys[0].value;
// }
//}
private void SetKeys(float value)
{
foreach (AnimationClip a in allAnimatinClips)
{
var bindigs = AnimationUtility.GetCurveBindings(a);
var AnimationCurves = AnimationUtility.GetEditorCurve(a, bindigs[5]);
var keys = AnimationCurves.keys;
AnimationCurve TmpAnimationCurve;
for (int i = 0; i < keys.Length; ++i)
{
keys[i].value += value;
}
TmpAnimationCurve = new AnimationCurve(keys);
a.SetCurve("", typeof(Transform), "m_LocalPosition.y", TmpAnimationCurve);
//for (int i = 0; i < bindigs.Length; ++i)
//{
// Debug.Log(i + " : " + bindigs[i].propertyName);
//}
}
}
//private void ResetKeys()
//{
// foreach (AnimationClip a in allAnimatinClips)
// {
// var bindigs = AnimationUtility.GetCurveBindings(a);
// var AnimationCurves = AnimationUtility.GetEditorCurve(a, bindigs[5]);
// var keys = AnimationCurves.keys;
// AnimationCurve TmpAnimationCurve;
// for (int i = 0; i < keys.Length; ++i)
// {
// keys[i].value = curAniValue;
// }
// TmpAnimationCurve = new AnimationCurve(keys);
// a.SetCurve("", typeof(Transform), "m_LocalPosition.y", TmpAnimationCurve);
// //for (int i = 0; i < bindigs.Length; ++i)
// //{
// // Debug.Log(i + " : " + bindigs[i].propertyName);
// //}
// }
//}
private void OnGUI()
{
GUILayout.BeginHorizontal();
GUILayout.Label("输入每次移动的单位: ");
addvalue = EditorGUILayout.FloatField(addvalue);
GUILayout.EndHorizontal();
if (GUILayout.Button("UP"))
{
ClearAll();
GetAnimationClips();
SetKeys(addvalue);
}
if (GUILayout.Button("Down"))
{
ClearAll();
GetAnimationClips();
SetKeys(-addvalue);
}
}
}