net.dreditor.phraseanimations 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/AnimData.cs +41 -41
- package/AnimData.cs.meta +11 -11
- package/DREditor.PhraseAnimations.asmdef +19 -19
- package/DREditor.PhraseAnimations.asmdef.meta +7 -7
- package/Editor/CompactPhraseTypeEditor.cs +96 -96
- package/Editor/CompactPhraseTypeEditor.cs.meta +11 -11
- package/Editor/PhraseAnimationEditor.cs +179 -179
- package/Editor/PhraseAnimationEditor.cs.meta +11 -11
- package/Editor/PhraseAnimationTypeEditor.cs +24 -24
- package/Editor/PhraseAnimationTypeEditor.cs.meta +11 -11
- package/Editor/PhraseAnimationTypeList.cs +23 -23
- package/Editor/PhraseAnimationTypeList.cs.meta +11 -11
- package/Editor/PhraseFadeTypeEditor.cs +18 -18
- package/Editor/PhraseFadeTypeEditor.cs.meta +11 -11
- package/Editor/PhraseRotationTypeEditor.cs +19 -19
- package/Editor/PhraseRotationTypeEditor.cs.meta +11 -11
- package/Editor/PhraseScaleTypeEditor.cs +19 -19
- package/Editor/PhraseScaleTypeEditor.cs.meta +11 -11
- package/Editor/PhraseTransformTypeEditor.cs +18 -18
- package/Editor/PhraseTransformTypeEditor.cs.meta +11 -11
- package/Editor/PhraseTypeEditor.cs +277 -277
- package/Editor/PhraseTypeEditor.cs.meta +11 -11
- package/Editor.meta +8 -8
- package/IPhraseAnimationType.cs +16 -16
- package/IPhraseAnimationType.cs.meta +11 -11
- package/PhraseAnimation.cs +73 -73
- package/PhraseAnimation.cs.meta +11 -11
- package/PhraseAnimationCompact.cs +44 -44
- package/PhraseAnimationCompact.cs.meta +11 -11
- package/PhraseAnimationHandler.cs +135 -135
- package/PhraseAnimationHandler.cs.meta +11 -11
- package/PhraseAnimationTypeBase.cs +53 -53
- package/PhraseAnimationTypeBase.cs.meta +11 -11
- package/PhraseFadeType.cs +19 -19
- package/PhraseFadeType.cs.meta +11 -11
- package/PhraseRotationType.cs +27 -27
- package/PhraseRotationType.cs.meta +11 -11
- package/PhraseScaleType.cs +25 -25
- package/PhraseScaleType.cs.meta +11 -11
- package/PhraseTransformType.cs +25 -25
- package/PhraseTransformType.cs.meta +11 -11
- package/package.json +42 -37
- package/package.json.meta +7 -7
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
#if UNITY_EDITOR
|
|
3
|
-
using DREditor.Editor.Utility;
|
|
4
|
-
using UnityEditor;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
|
|
7
|
-
namespace DREditor.PhraseAnimations.Editor
|
|
8
|
-
{
|
|
9
|
-
/// <summary>
|
|
10
|
-
///
|
|
11
|
-
/// </summary>
|
|
12
|
-
public abstract class PhraseTypeEditor : ClassEditorBase
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
///
|
|
16
|
-
/// </summary>
|
|
17
|
-
protected PhraseAnimationTypeBase typeBaseTarget;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/// <inheritdoc/>
|
|
21
|
-
protected override void OnInspectorGUI()
|
|
22
|
-
{
|
|
23
|
-
typeBaseTarget = baseTarget as PhraseAnimationTypeBase;
|
|
24
|
-
|
|
25
|
-
DisplayType();
|
|
26
|
-
|
|
27
|
-
using (new EditorGUILayout.HorizontalScope())
|
|
28
|
-
{
|
|
29
|
-
DisplayStartTime();
|
|
30
|
-
|
|
31
|
-
DisplayDuration();
|
|
32
|
-
|
|
33
|
-
DisplayCurveButtons();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
DisplayGenerateCurves();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/// <summary>
|
|
40
|
-
///
|
|
41
|
-
/// </summary>
|
|
42
|
-
protected virtual void DisplayStartTime()
|
|
43
|
-
{
|
|
44
|
-
typeBaseTarget.SetStartTime(HandyFields.FloatField("Start Time: ", typeBaseTarget.startTime, 30));
|
|
45
|
-
|
|
46
|
-
if (typeBaseTarget.startTime < 0)
|
|
47
|
-
typeBaseTarget.SetStartTime(0);
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/// <summary>
|
|
52
|
-
///
|
|
53
|
-
/// </summary>
|
|
54
|
-
protected virtual void DisplayDuration()
|
|
55
|
-
{
|
|
56
|
-
float fallBackDuration = typeBaseTarget.duration;
|
|
57
|
-
|
|
58
|
-
typeBaseTarget.SetDuration(HandyFields.FloatField("Duration: ", typeBaseTarget.duration, 30));
|
|
59
|
-
|
|
60
|
-
if (typeBaseTarget.duration <= 0)
|
|
61
|
-
{
|
|
62
|
-
if (fallBackDuration == 0)
|
|
63
|
-
typeBaseTarget.SetDuration(1);
|
|
64
|
-
else
|
|
65
|
-
typeBaseTarget.SetDuration(fallBackDuration);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/// <summary>
|
|
70
|
-
///
|
|
71
|
-
/// </summary>
|
|
72
|
-
protected virtual void DisplayCurveButtons()
|
|
73
|
-
{
|
|
74
|
-
if (typeBaseTarget.animationCurves.Count != 0)
|
|
75
|
-
{
|
|
76
|
-
if (GUILayout.Button("Update Curves"))
|
|
77
|
-
UpdateCurves();
|
|
78
|
-
|
|
79
|
-
if (GUILayout.Button("Reset Curves"))
|
|
80
|
-
ResetCurves();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/// <summary>
|
|
85
|
-
///
|
|
86
|
-
/// </summary>
|
|
87
|
-
protected virtual void DisplayGenerateCurves()
|
|
88
|
-
{
|
|
89
|
-
if (typeBaseTarget.animationCurves.Count == 0)
|
|
90
|
-
{
|
|
91
|
-
if (GUILayout.Button("Generate Curves"))
|
|
92
|
-
GenerateCurves();
|
|
93
|
-
}
|
|
94
|
-
else
|
|
95
|
-
using (new EditorGUILayout.HorizontalScope())
|
|
96
|
-
DisplayCurves();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/// <summary>
|
|
100
|
-
///
|
|
101
|
-
/// </summary>
|
|
102
|
-
protected virtual void GenerateCurves()
|
|
103
|
-
{
|
|
104
|
-
for (int i = 0; i < typeBaseTarget.CurveCount; i++)
|
|
105
|
-
typeBaseTarget.animationCurves.Add(new AnimationCurve());
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/// <summary>
|
|
109
|
-
///
|
|
110
|
-
/// </summary>
|
|
111
|
-
protected abstract void DisplayType();
|
|
112
|
-
|
|
113
|
-
/// <summary>
|
|
114
|
-
///
|
|
115
|
-
/// </summary>
|
|
116
|
-
protected abstract void DisplayCurves();
|
|
117
|
-
|
|
118
|
-
/// <summary>
|
|
119
|
-
///
|
|
120
|
-
/// </summary>
|
|
121
|
-
protected abstract void UpdateCurves();
|
|
122
|
-
|
|
123
|
-
/// <summary>
|
|
124
|
-
///
|
|
125
|
-
/// </summary>
|
|
126
|
-
protected virtual void ResetCurves()
|
|
127
|
-
{
|
|
128
|
-
typeBaseTarget.animationCurves.Clear();
|
|
129
|
-
|
|
130
|
-
GenerateCurves();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/// <summary>
|
|
135
|
-
///
|
|
136
|
-
/// </summary>
|
|
137
|
-
/// <param name="curve"></param>
|
|
138
|
-
/// <param name="start"></param>
|
|
139
|
-
/// <param name="end"></param>
|
|
140
|
-
/// <returns></returns>
|
|
141
|
-
protected virtual AnimationCurve DisplayCurve(AnimationCurve curve, float start, float end)
|
|
142
|
-
{
|
|
143
|
-
if (curve.keys.Length == 0)
|
|
144
|
-
{
|
|
145
|
-
curve.AddKey(typeBaseTarget.startTime, start);
|
|
146
|
-
|
|
147
|
-
curve.AddKey(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
try // Clicking the curve field would call an internal unity error but still works so this try is here to mitigate that.
|
|
151
|
-
{
|
|
152
|
-
curve = EditorGUILayout.CurveField(curve);
|
|
153
|
-
}
|
|
154
|
-
catch { }
|
|
155
|
-
|
|
156
|
-
return curve;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/// <summary>
|
|
160
|
-
///
|
|
161
|
-
/// </summary>
|
|
162
|
-
/// <param name="curve"></param>
|
|
163
|
-
/// <param name="start"></param>
|
|
164
|
-
/// <param name="end"></param>
|
|
165
|
-
/// <returns></returns>
|
|
166
|
-
protected virtual AnimationCurve UpdateKey(AnimationCurve curve, float start, float end)
|
|
167
|
-
{
|
|
168
|
-
Keyframe oldStartTimeKey = curve.keys[0];
|
|
169
|
-
|
|
170
|
-
Keyframe oldDurationTimeKey = curve.keys[^1];
|
|
171
|
-
|
|
172
|
-
curve.keys = ValidateCurves(oldStartTimeKey, oldDurationTimeKey, curve, start, end);
|
|
173
|
-
|
|
174
|
-
return curve;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
#region Keyframe Validation
|
|
178
|
-
|
|
179
|
-
/// <summary>
|
|
180
|
-
///
|
|
181
|
-
/// </summary>
|
|
182
|
-
/// <param name="oldStart"></param>
|
|
183
|
-
/// <param name="oldDuration"></param>
|
|
184
|
-
/// <param name="curve"></param>
|
|
185
|
-
/// <param name="start"></param>
|
|
186
|
-
/// <param name="end"></param>
|
|
187
|
-
/// <returns></returns>
|
|
188
|
-
protected virtual Keyframe[] ValidateCurves(Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve, float start, float end)
|
|
189
|
-
{
|
|
190
|
-
if (ValidateMovedKey(curve, start, end))
|
|
191
|
-
return curve.keys;
|
|
192
|
-
|
|
193
|
-
Keyframe[] newKeys = ValidateNewKeys(oldStart, oldDuration, curve);
|
|
194
|
-
|
|
195
|
-
newKeys[0] = new(typeBaseTarget.startTime, start);
|
|
196
|
-
|
|
197
|
-
newKeys[curve.keys.Length - 1] = new(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
198
|
-
|
|
199
|
-
return newKeys;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/// <summary>
|
|
203
|
-
///
|
|
204
|
-
/// </summary>
|
|
205
|
-
/// <param name="curve"></param>
|
|
206
|
-
/// <param name="start"></param>
|
|
207
|
-
/// <param name="end"></param>
|
|
208
|
-
/// <returns></returns>
|
|
209
|
-
protected virtual bool ValidateMovedKey(AnimationCurve curve, float start, float end)
|
|
210
|
-
{
|
|
211
|
-
Keyframe newStart = new(typeBaseTarget.startTime, start);
|
|
212
|
-
|
|
213
|
-
Keyframe newDuration = new(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
214
|
-
|
|
215
|
-
if (curve.keys[^1].time == newDuration.time && curve.keys[0].time == newStart.time)
|
|
216
|
-
{
|
|
217
|
-
if (curve.keys[^1].value == newDuration.value && curve.keys[0].value == newStart.value)
|
|
218
|
-
return true;
|
|
219
|
-
else
|
|
220
|
-
{
|
|
221
|
-
curve.MoveKey(0, new(0, start));
|
|
222
|
-
|
|
223
|
-
curve.MoveKey(curve.keys.Length - 1, new(typeBaseTarget.startTime + typeBaseTarget.duration, end));
|
|
224
|
-
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/// <summary>
|
|
233
|
-
///
|
|
234
|
-
/// </summary>
|
|
235
|
-
/// <param name="oldStart"></param>
|
|
236
|
-
/// <param name="oldDuration"></param>
|
|
237
|
-
/// <param name="curve"></param>
|
|
238
|
-
/// <returns></returns>
|
|
239
|
-
protected virtual Keyframe[] ValidateNewKeys(Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve)
|
|
240
|
-
{
|
|
241
|
-
Keyframe[] newKeys = new Keyframe[curve.keys.Length];
|
|
242
|
-
|
|
243
|
-
if (curve.keys.Length > 2)
|
|
244
|
-
UpdateNewKeys(newKeys, oldStart, oldDuration, curve);
|
|
245
|
-
|
|
246
|
-
return newKeys;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/// <summary>
|
|
250
|
-
///
|
|
251
|
-
/// </summary>
|
|
252
|
-
/// <param name="newKeys"></param>
|
|
253
|
-
/// <param name="oldStart"></param>
|
|
254
|
-
/// <param name="oldDuration"></param>
|
|
255
|
-
/// <param name="curve"></param>
|
|
256
|
-
protected virtual void UpdateNewKeys(Keyframe[] newKeys, Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve)
|
|
257
|
-
{
|
|
258
|
-
float startOffset = typeBaseTarget.startTime - oldStart.time;
|
|
259
|
-
|
|
260
|
-
float durationOffset = (typeBaseTarget.startTime + typeBaseTarget.duration) - oldDuration.time;
|
|
261
|
-
|
|
262
|
-
for (int i = 1; i <= newKeys.Length - 2; i++)
|
|
263
|
-
if (curve.keys[i].time <= typeBaseTarget.startTime)
|
|
264
|
-
newKeys[i] = new(curve.keys[i].time + startOffset, curve.keys[i].value);
|
|
265
|
-
else if (curve.keys[i].time >= typeBaseTarget.startTime + typeBaseTarget.duration)
|
|
266
|
-
newKeys[i] = new(curve.keys[i].time + durationOffset, curve.keys[i].value);
|
|
267
|
-
else
|
|
268
|
-
{
|
|
269
|
-
float behind = curve.keys[i].time - curve.keys[i - 1].time;
|
|
270
|
-
|
|
271
|
-
newKeys[i] = new(curve.keys[i].time + behind, curve.keys[i].value);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
#endregion
|
|
276
|
-
}
|
|
277
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if UNITY_EDITOR
|
|
3
|
+
using DREditor.Editor.Utility;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.PhraseAnimations.Editor
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
public abstract class PhraseTypeEditor : ClassEditorBase
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
protected PhraseAnimationTypeBase typeBaseTarget;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/// <inheritdoc/>
|
|
21
|
+
protected override void OnInspectorGUI()
|
|
22
|
+
{
|
|
23
|
+
typeBaseTarget = baseTarget as PhraseAnimationTypeBase;
|
|
24
|
+
|
|
25
|
+
DisplayType();
|
|
26
|
+
|
|
27
|
+
using (new EditorGUILayout.HorizontalScope())
|
|
28
|
+
{
|
|
29
|
+
DisplayStartTime();
|
|
30
|
+
|
|
31
|
+
DisplayDuration();
|
|
32
|
+
|
|
33
|
+
DisplayCurveButtons();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
DisplayGenerateCurves();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
///
|
|
41
|
+
/// </summary>
|
|
42
|
+
protected virtual void DisplayStartTime()
|
|
43
|
+
{
|
|
44
|
+
typeBaseTarget.SetStartTime(HandyFields.FloatField("Start Time: ", typeBaseTarget.startTime, 30));
|
|
45
|
+
|
|
46
|
+
if (typeBaseTarget.startTime < 0)
|
|
47
|
+
typeBaseTarget.SetStartTime(0);
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
protected virtual void DisplayDuration()
|
|
55
|
+
{
|
|
56
|
+
float fallBackDuration = typeBaseTarget.duration;
|
|
57
|
+
|
|
58
|
+
typeBaseTarget.SetDuration(HandyFields.FloatField("Duration: ", typeBaseTarget.duration, 30));
|
|
59
|
+
|
|
60
|
+
if (typeBaseTarget.duration <= 0)
|
|
61
|
+
{
|
|
62
|
+
if (fallBackDuration == 0)
|
|
63
|
+
typeBaseTarget.SetDuration(1);
|
|
64
|
+
else
|
|
65
|
+
typeBaseTarget.SetDuration(fallBackDuration);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
///
|
|
71
|
+
/// </summary>
|
|
72
|
+
protected virtual void DisplayCurveButtons()
|
|
73
|
+
{
|
|
74
|
+
if (typeBaseTarget.animationCurves.Count != 0)
|
|
75
|
+
{
|
|
76
|
+
if (GUILayout.Button("Update Curves"))
|
|
77
|
+
UpdateCurves();
|
|
78
|
+
|
|
79
|
+
if (GUILayout.Button("Reset Curves"))
|
|
80
|
+
ResetCurves();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
///
|
|
86
|
+
/// </summary>
|
|
87
|
+
protected virtual void DisplayGenerateCurves()
|
|
88
|
+
{
|
|
89
|
+
if (typeBaseTarget.animationCurves.Count == 0)
|
|
90
|
+
{
|
|
91
|
+
if (GUILayout.Button("Generate Curves"))
|
|
92
|
+
GenerateCurves();
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
using (new EditorGUILayout.HorizontalScope())
|
|
96
|
+
DisplayCurves();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// <summary>
|
|
100
|
+
///
|
|
101
|
+
/// </summary>
|
|
102
|
+
protected virtual void GenerateCurves()
|
|
103
|
+
{
|
|
104
|
+
for (int i = 0; i < typeBaseTarget.CurveCount; i++)
|
|
105
|
+
typeBaseTarget.animationCurves.Add(new AnimationCurve());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
///
|
|
110
|
+
/// </summary>
|
|
111
|
+
protected abstract void DisplayType();
|
|
112
|
+
|
|
113
|
+
/// <summary>
|
|
114
|
+
///
|
|
115
|
+
/// </summary>
|
|
116
|
+
protected abstract void DisplayCurves();
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
///
|
|
120
|
+
/// </summary>
|
|
121
|
+
protected abstract void UpdateCurves();
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
///
|
|
125
|
+
/// </summary>
|
|
126
|
+
protected virtual void ResetCurves()
|
|
127
|
+
{
|
|
128
|
+
typeBaseTarget.animationCurves.Clear();
|
|
129
|
+
|
|
130
|
+
GenerateCurves();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
///
|
|
136
|
+
/// </summary>
|
|
137
|
+
/// <param name="curve"></param>
|
|
138
|
+
/// <param name="start"></param>
|
|
139
|
+
/// <param name="end"></param>
|
|
140
|
+
/// <returns></returns>
|
|
141
|
+
protected virtual AnimationCurve DisplayCurve(AnimationCurve curve, float start, float end)
|
|
142
|
+
{
|
|
143
|
+
if (curve.keys.Length == 0)
|
|
144
|
+
{
|
|
145
|
+
curve.AddKey(typeBaseTarget.startTime, start);
|
|
146
|
+
|
|
147
|
+
curve.AddKey(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try // Clicking the curve field would call an internal unity error but still works so this try is here to mitigate that.
|
|
151
|
+
{
|
|
152
|
+
curve = EditorGUILayout.CurveField(curve);
|
|
153
|
+
}
|
|
154
|
+
catch { }
|
|
155
|
+
|
|
156
|
+
return curve;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// <summary>
|
|
160
|
+
///
|
|
161
|
+
/// </summary>
|
|
162
|
+
/// <param name="curve"></param>
|
|
163
|
+
/// <param name="start"></param>
|
|
164
|
+
/// <param name="end"></param>
|
|
165
|
+
/// <returns></returns>
|
|
166
|
+
protected virtual AnimationCurve UpdateKey(AnimationCurve curve, float start, float end)
|
|
167
|
+
{
|
|
168
|
+
Keyframe oldStartTimeKey = curve.keys[0];
|
|
169
|
+
|
|
170
|
+
Keyframe oldDurationTimeKey = curve.keys[^1];
|
|
171
|
+
|
|
172
|
+
curve.keys = ValidateCurves(oldStartTimeKey, oldDurationTimeKey, curve, start, end);
|
|
173
|
+
|
|
174
|
+
return curve;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
#region Keyframe Validation
|
|
178
|
+
|
|
179
|
+
/// <summary>
|
|
180
|
+
///
|
|
181
|
+
/// </summary>
|
|
182
|
+
/// <param name="oldStart"></param>
|
|
183
|
+
/// <param name="oldDuration"></param>
|
|
184
|
+
/// <param name="curve"></param>
|
|
185
|
+
/// <param name="start"></param>
|
|
186
|
+
/// <param name="end"></param>
|
|
187
|
+
/// <returns></returns>
|
|
188
|
+
protected virtual Keyframe[] ValidateCurves(Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve, float start, float end)
|
|
189
|
+
{
|
|
190
|
+
if (ValidateMovedKey(curve, start, end))
|
|
191
|
+
return curve.keys;
|
|
192
|
+
|
|
193
|
+
Keyframe[] newKeys = ValidateNewKeys(oldStart, oldDuration, curve);
|
|
194
|
+
|
|
195
|
+
newKeys[0] = new(typeBaseTarget.startTime, start);
|
|
196
|
+
|
|
197
|
+
newKeys[curve.keys.Length - 1] = new(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
198
|
+
|
|
199
|
+
return newKeys;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// <summary>
|
|
203
|
+
///
|
|
204
|
+
/// </summary>
|
|
205
|
+
/// <param name="curve"></param>
|
|
206
|
+
/// <param name="start"></param>
|
|
207
|
+
/// <param name="end"></param>
|
|
208
|
+
/// <returns></returns>
|
|
209
|
+
protected virtual bool ValidateMovedKey(AnimationCurve curve, float start, float end)
|
|
210
|
+
{
|
|
211
|
+
Keyframe newStart = new(typeBaseTarget.startTime, start);
|
|
212
|
+
|
|
213
|
+
Keyframe newDuration = new(typeBaseTarget.startTime + typeBaseTarget.duration, end);
|
|
214
|
+
|
|
215
|
+
if (curve.keys[^1].time == newDuration.time && curve.keys[0].time == newStart.time)
|
|
216
|
+
{
|
|
217
|
+
if (curve.keys[^1].value == newDuration.value && curve.keys[0].value == newStart.value)
|
|
218
|
+
return true;
|
|
219
|
+
else
|
|
220
|
+
{
|
|
221
|
+
curve.MoveKey(0, new(0, start));
|
|
222
|
+
|
|
223
|
+
curve.MoveKey(curve.keys.Length - 1, new(typeBaseTarget.startTime + typeBaseTarget.duration, end));
|
|
224
|
+
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// <summary>
|
|
233
|
+
///
|
|
234
|
+
/// </summary>
|
|
235
|
+
/// <param name="oldStart"></param>
|
|
236
|
+
/// <param name="oldDuration"></param>
|
|
237
|
+
/// <param name="curve"></param>
|
|
238
|
+
/// <returns></returns>
|
|
239
|
+
protected virtual Keyframe[] ValidateNewKeys(Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve)
|
|
240
|
+
{
|
|
241
|
+
Keyframe[] newKeys = new Keyframe[curve.keys.Length];
|
|
242
|
+
|
|
243
|
+
if (curve.keys.Length > 2)
|
|
244
|
+
UpdateNewKeys(newKeys, oldStart, oldDuration, curve);
|
|
245
|
+
|
|
246
|
+
return newKeys;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/// <summary>
|
|
250
|
+
///
|
|
251
|
+
/// </summary>
|
|
252
|
+
/// <param name="newKeys"></param>
|
|
253
|
+
/// <param name="oldStart"></param>
|
|
254
|
+
/// <param name="oldDuration"></param>
|
|
255
|
+
/// <param name="curve"></param>
|
|
256
|
+
protected virtual void UpdateNewKeys(Keyframe[] newKeys, Keyframe oldStart, Keyframe oldDuration, AnimationCurve curve)
|
|
257
|
+
{
|
|
258
|
+
float startOffset = typeBaseTarget.startTime - oldStart.time;
|
|
259
|
+
|
|
260
|
+
float durationOffset = (typeBaseTarget.startTime + typeBaseTarget.duration) - oldDuration.time;
|
|
261
|
+
|
|
262
|
+
for (int i = 1; i <= newKeys.Length - 2; i++)
|
|
263
|
+
if (curve.keys[i].time <= typeBaseTarget.startTime)
|
|
264
|
+
newKeys[i] = new(curve.keys[i].time + startOffset, curve.keys[i].value);
|
|
265
|
+
else if (curve.keys[i].time >= typeBaseTarget.startTime + typeBaseTarget.duration)
|
|
266
|
+
newKeys[i] = new(curve.keys[i].time + durationOffset, curve.keys[i].value);
|
|
267
|
+
else
|
|
268
|
+
{
|
|
269
|
+
float behind = curve.keys[i].time - curve.keys[i - 1].time;
|
|
270
|
+
|
|
271
|
+
newKeys[i] = new(curve.keys[i].time + behind, curve.keys[i].value);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#endregion
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
278
|
#endif
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: e43b5c8d5ddfb9b45b2eef3bfa858904
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: e43b5c8d5ddfb9b45b2eef3bfa858904
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Editor.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 056fb7e0cf9b7944fbd458061aab0311
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 056fb7e0cf9b7944fbd458061aab0311
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
package/IPhraseAnimationType.cs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using UnityEngine;
|
|
3
|
-
|
|
4
|
-
namespace DREditor.PhraseAnimations
|
|
5
|
-
{
|
|
6
|
-
/// <summary>
|
|
7
|
-
///
|
|
8
|
-
/// </summary>
|
|
9
|
-
public interface IPhraseAnimationType
|
|
10
|
-
{
|
|
11
|
-
/// <summary>
|
|
12
|
-
///
|
|
13
|
-
/// </summary>
|
|
14
|
-
/// <param name="clip"></param>
|
|
15
|
-
void Initialize(AnimationClip clip);
|
|
16
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace DREditor.PhraseAnimations
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
///
|
|
8
|
+
/// </summary>
|
|
9
|
+
public interface IPhraseAnimationType
|
|
10
|
+
{
|
|
11
|
+
/// <summary>
|
|
12
|
+
///
|
|
13
|
+
/// </summary>
|
|
14
|
+
/// <param name="clip"></param>
|
|
15
|
+
void Initialize(AnimationClip clip);
|
|
16
|
+
}
|
|
17
17
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 4e8222b99a549774cae8a4323283f344
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 4e8222b99a549774cae8a4323283f344
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|