Skip to content

Commit 12de761

Browse files
author
Unity Technologies
committed
Unity 2018.1.0a5 C# reference source code
1 parent d9c9752 commit 12de761

441 files changed

Lines changed: 17121 additions & 11389 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ void OnEnable()
190190
m_EnableRotation = serializedObject.FindProperty("m_EditorData.packingParameters.enableRotation");
191191
m_Padding = serializedObject.FindProperty("m_EditorData.packingParameters.padding");
192192

193-
m_Hash = serializedObject.FindProperty("m_EditorData.hashString").stringValue;
194193
m_MasterAtlas = serializedObject.FindProperty("m_MasterAtlas");
195194
m_BindAsDefault = serializedObject.FindProperty("m_EditorData.bindAsDefault");
196195
m_VariantMultiplier = serializedObject.FindProperty("m_EditorData.variantMultiplier");

Editor/Mono/Animation/AnimationWindow/AnimationWindowCurve.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,32 @@ public AnimationWindowCurve(AnimationClip clip, EditorCurveBinding binding, Syst
5959
LoadKeyframes(clip);
6060
}
6161

62+
public void LoadKeyframes(AnimationCurve curve)
63+
{
64+
if (curve == null)
65+
return;
66+
67+
for (int i = 0; i < curve.length; i++)
68+
m_Keyframes.Add(new AnimationWindowKeyframe(this, curve[i]));
69+
}
70+
6271
public void LoadKeyframes(AnimationClip clip)
6372
{
6473
m_Keyframes = new List<AnimationWindowKeyframe>();
6574

6675
if (!m_Binding.isPPtrCurve)
6776
{
6877
AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);
69-
for (int i = 0; curve != null && i < curve.length; i++)
70-
m_Keyframes.Add(new AnimationWindowKeyframe(this, curve[i]));
78+
LoadKeyframes(curve);
7179
}
7280
else
7381
{
7482
ObjectReferenceKeyframe[] curve = AnimationUtility.GetObjectReferenceCurve(clip, binding);
75-
for (int i = 0; curve != null && i < curve.Length; i++)
76-
m_Keyframes.Add(new AnimationWindowKeyframe(this, curve[i]));
83+
if (curve != null)
84+
{
85+
for (int i = 0; i < curve.Length; i++)
86+
m_Keyframes.Add(new AnimationWindowKeyframe(this, curve[i]));
87+
}
7788
}
7889
}
7990

@@ -177,8 +188,7 @@ public AnimationCurve ToAnimationCurve()
177188
// Make sure we don't get two keyframes in an exactly the same time. We just ignore those.
178189
if (Mathf.Abs(m_Keyframes[i].time - lastFrameTime) > AnimationWindowCurve.timeEpsilon)
179190
{
180-
Keyframe newKeyframe = new Keyframe(m_Keyframes[i].time, (float)m_Keyframes[i].value, m_Keyframes[i].m_InTangent, m_Keyframes[i].m_OutTangent);
181-
newKeyframe.tangentMode = m_Keyframes[i].m_TangentMode;
191+
Keyframe newKeyframe = m_Keyframes[i].ToKeyframe();
182192
keys.Add(newKeyframe);
183193
lastFrameTime = m_Keyframes[i].time;
184194
}
@@ -200,9 +210,7 @@ public ObjectReferenceKeyframe[] ToObjectCurve()
200210
// Make sure we don't get two keyframes in an exactly the same time. We just ignore those.
201211
if (Mathf.Abs(m_Keyframes[i].time - lastFrameTime) > AnimationWindowCurve.timeEpsilon)
202212
{
203-
ObjectReferenceKeyframe newKeyframe = new ObjectReferenceKeyframe();
204-
newKeyframe.time = m_Keyframes[i].time;
205-
newKeyframe.value = (UnityEngine.Object)m_Keyframes[i].value;
213+
ObjectReferenceKeyframe newKeyframe = m_Keyframes[i].ToObjectReferenceKeyframe();
206214
lastFrameTime = newKeyframe.time;
207215
keys.Add(newKeyframe);
208216
}
@@ -247,8 +255,8 @@ public object Evaluate(float time)
247255
else
248256
{
249257
// Create an animation curve stub and evaluate.
250-
Keyframe keyframe = new Keyframe(key.time, (float)key.value, key.m_InTangent, key.m_OutTangent);
251-
Keyframe nextKeyframe = new Keyframe(nextKey.time, (float)nextKey.value, nextKey.m_InTangent, nextKey.m_OutTangent);
258+
Keyframe keyframe = key.ToKeyframe();
259+
Keyframe nextKeyframe = nextKey.ToKeyframe();
252260

253261
AnimationCurve animationCurve = new AnimationCurve();
254262
animationCurve.keys = new Keyframe[2] { keyframe, nextKeyframe };
@@ -308,5 +316,10 @@ public void RemoveKeysAtRange(float startTime, float endTime)
308316
m_Keyframes.RemoveAt(i);
309317
}
310318
}
319+
320+
public void Clear()
321+
{
322+
m_Keyframes.Clear();
323+
}
311324
}
312325
}

Editor/Mono/Animation/AnimationWindow/AnimationWindowKeyframe.cs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ internal class AnimationWindowKeyframe
1111
{
1212
public float m_InTangent;
1313
public float m_OutTangent;
14+
public float m_InWeight;
15+
public float m_OutWeight;
16+
public WeightedMode m_WeightedMode;
1417
public int m_TangentMode;
1518
public int m_TimeHash;
1619
int m_Hash;
@@ -49,6 +52,24 @@ public float outTangent
4952
set { m_OutTangent = value; }
5053
}
5154

55+
public float inWeight
56+
{
57+
get { return m_InWeight; }
58+
set { m_InWeight = value; }
59+
}
60+
61+
public float outWeight
62+
{
63+
get { return m_OutWeight; }
64+
set { m_OutWeight = value; }
65+
}
66+
67+
public WeightedMode weightedMode
68+
{
69+
get { return m_WeightedMode; }
70+
set { m_WeightedMode = value; }
71+
}
72+
5273
public AnimationWindowCurve curve
5374
{
5475
get { return m_curve; }
@@ -73,6 +94,9 @@ public AnimationWindowKeyframe(AnimationWindowKeyframe key)
7394
this.curve = key.curve;
7495
this.m_InTangent = key.m_InTangent;
7596
this.m_OutTangent = key.m_OutTangent;
97+
this.m_InWeight = key.inWeight;
98+
this.m_OutWeight = key.outWeight;
99+
this.m_WeightedMode = key.weightedMode;
76100
this.m_TangentMode = key.m_TangentMode;
77101
this.m_curve = key.m_curve;
78102
}
@@ -84,7 +108,10 @@ public AnimationWindowKeyframe(AnimationWindowCurve curve, Keyframe key)
84108
this.curve = curve;
85109
this.m_InTangent = key.inTangent;
86110
this.m_OutTangent = key.outTangent;
87-
this.m_TangentMode = key.tangentMode;
111+
this.m_InWeight = key.inWeight;
112+
this.m_OutWeight = key.outWeight;
113+
this.m_WeightedMode = key.weightedMode;
114+
this.m_TangentMode = key.tangentModeInternal;
88115
this.m_curve = curve;
89116
}
90117

@@ -121,5 +148,27 @@ public int GetIndex()
121148
}
122149
return -1;
123150
}
151+
152+
public Keyframe ToKeyframe()
153+
{
154+
var keyframe = new Keyframe(time, (float)value, inTangent, outTangent);
155+
156+
keyframe.tangentModeInternal = m_TangentMode;
157+
keyframe.weightedMode = weightedMode;
158+
keyframe.inWeight = inWeight;
159+
keyframe.outWeight = outWeight;
160+
161+
return keyframe;
162+
}
163+
164+
public ObjectReferenceKeyframe ToObjectReferenceKeyframe()
165+
{
166+
var keyframe = new ObjectReferenceKeyframe();
167+
168+
keyframe.time = time;
169+
keyframe.value = (UnityEngine.Object)value;
170+
171+
return keyframe;
172+
}
124173
}
125174
}

Editor/Mono/Animation/AnimationWindow/AnimationWindowState.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ public void OnEnable()
304304
// NoOps...
305305
onStartLiveEdit += () => {};
306306
onEndLiveEdit += () => {};
307-
onFrameRateChange += (float frameRate) => {};
308307

309308
if (m_ControlInterface == null)
310309
m_ControlInterface = CreateInstance(typeof(AnimationWindowControl)) as AnimationWindowControl;
@@ -331,7 +330,8 @@ public void OnDestroy()
331330

332331
public void OnSelectionChanged()
333332
{
334-
onFrameRateChange(frameRate);
333+
if (onFrameRateChange != null)
334+
onFrameRateChange(frameRate);
335335

336336
// reset back time at 0 upon selection change.
337337
controlInterface.OnSelectionChanged();
@@ -1508,7 +1508,8 @@ public float frameRate
15081508
if (m_FrameRate != value)
15091509
{
15101510
m_FrameRate = value;
1511-
onFrameRateChange(m_FrameRate);
1511+
if (onFrameRateChange != null)
1512+
onFrameRateChange(m_FrameRate);
15121513
}
15131514
}
15141515
}

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve cu
185185
}
186186
else if (type == typeof(bool) || type == typeof(float) || type == typeof(int))
187187
{
188-
keyframe = new AnimationWindowKeyframe();
189-
190-
// Create temporary curve for getting proper tangents
191-
AnimationCurve animationCurve = curve.ToAnimationCurve();
192-
193188
Keyframe tempKey = new Keyframe(time.time, (float)value);
194189
if (type == typeof(bool) || type == typeof(int))
195190
{
@@ -205,10 +200,12 @@ public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve cu
205200
}
206201

207202
AnimationUtility.SetKeyBroken(ref tempKey, true);
208-
keyframe.m_TangentMode = tempKey.tangentMode;
209203
}
210204
else
211205
{
206+
// Create temporary curve for getting proper tangents
207+
AnimationCurve animationCurve = curve.ToAnimationCurve();
208+
212209
int keyIndex = animationCurve.AddKey(tempKey);
213210
if (keyIndex != -1)
214211
{
@@ -218,15 +215,12 @@ public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve cu
218215
AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyIndex);
219216

220217
CurveUtility.SetKeyModeFromContext(animationCurve, keyIndex);
221-
keyframe.m_TangentMode = animationCurve[keyIndex].tangentMode;
222-
keyframe.m_InTangent = animationCurve[keyIndex].inTangent;
223-
keyframe.m_OutTangent = animationCurve[keyIndex].outTangent;
218+
219+
tempKey = animationCurve[keyIndex];
224220
}
225221
}
226222

227-
keyframe.time = time.time;
228-
keyframe.value = value;
229-
keyframe.curve = curve;
223+
keyframe = new AnimationWindowKeyframe(curve, tempKey);
230224
curve.AddKeyframe(keyframe, time);
231225
}
232226

0 commit comments

Comments
 (0)