Skip to content

Commit 96f4367

Browse files
author
Unity Technologies
committed
Unity 2017.1.0a6 C# reference source code
1 parent bdf9337 commit 96f4367

File tree

143 files changed

+1713
-1153
lines changed

Some content is hidden

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

143 files changed

+1713
-1153
lines changed

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -692,18 +692,6 @@ private void ValidateCurveList()
692692
*/
693693
}
694694

695-
void UpdateTangentsFromSelection()
696-
{
697-
foreach (CurveSelection cs in selectedCurves)
698-
{
699-
AnimationCurve curve = GetCurveFromSelection(cs);
700-
if (curve == null)
701-
continue;
702-
703-
AnimationUtility.UpdateTangentsFromModeSurrounding(curve, cs.key);
704-
}
705-
}
706-
707695
Dictionary<int, int> m_CurveIDToIndexMap;
708696
private Dictionary<int, int> curveIDToIndexMap
709697
{
@@ -1614,12 +1602,11 @@ void UpdateCurvesFromPoints(SavedCurve.KeyFrameOperation action)
16141602

16151603
// We now have the list of keys to assign - let's get them back into the animation clip
16161604
cw.curve.keys = keysToAssign;
1605+
AnimationUtility.UpdateTangentsFromMode(cw.curve);
16171606
cw.changed = true;
16181607
}
16191608

16201609
selectedCurves = dragSelection;
1621-
1622-
UpdateTangentsFromSelection();
16231610
}
16241611

16251612
float SnapTime(float t)
@@ -3168,6 +3155,9 @@ void DrawCurvesTangents()
31683155
if (curve == null)
31693156
continue;
31703157

3158+
if (curve.length == 0)
3159+
continue;
3160+
31713161
if (IsLeftTangentEditable(sel) && GetKeyframeFromSelection(sel).time != curve.keys[0].time)
31723162
{
31733163
Vector2 leftTangent = GetPosition(new CurveSelection(sel.curveID, sel.key, CurveSelection.SelectionType.InTangent));
@@ -3198,6 +3188,11 @@ void DrawCurvesTangents()
31983188
continue;
31993189

32003190
AnimationCurve curve = curveWrapper.curve;
3191+
if (curve == null)
3192+
continue;
3193+
3194+
if (curve.length == 0)
3195+
continue;
32013196

32023197
if (IsLeftTangentEditable(sel) && GetKeyframeFromSelection(sel).time != curve.keys[0].time)
32033198
{

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum NormalizationMode
3636
CurveEditor m_CurveEditor;
3737

3838
AnimationCurve m_Curve;
39+
SerializedProperty m_Property;
3940
Color m_Color;
4041

4142
CurvePresetsContentsForPopupWindow m_CurvePresets;
@@ -73,6 +74,7 @@ public static AnimationCurve curve
7374
get { return CurveEditorWindow.instance.m_Curve; }
7475
set
7576
{
77+
CurveEditorWindow.instance.m_Property = null;
7678
if (value == null)
7779
{
7880
CurveEditorWindow.instance.m_Curve = null;
@@ -85,6 +87,28 @@ public static AnimationCurve curve
8587
}
8688
}
8789

90+
public static SerializedProperty property
91+
{
92+
get
93+
{
94+
return CurveEditorWindow.instance.m_Property;
95+
}
96+
set
97+
{
98+
if (value == null)
99+
{
100+
CurveEditorWindow.instance.m_Property = null;
101+
CurveEditorWindow.instance.m_Curve = null;
102+
}
103+
else
104+
{
105+
CurveEditorWindow.instance.m_Property = value.Copy();
106+
CurveEditorWindow.instance.m_Curve = value.hasMultipleDifferentValues ? new AnimationCurve() : value.animationCurveValue;
107+
CurveEditorWindow.instance.RefreshShownCurves();
108+
}
109+
}
110+
}
111+
88112
public static Color color
89113
{
90114
get { return CurveEditorWindow.instance.m_Color; }
@@ -450,6 +474,7 @@ void OnGUI()
450474
m_Curve.postWrapMode = animCurve.postWrapMode;
451475
m_Curve.preWrapMode = animCurve.preWrapMode;
452476
m_CurveEditor.SelectNone();
477+
RefreshShownCurves();
453478
SendEvent("CurveChanged", true);
454479
}
455480
if (Event.current.type == EventType.repaint)

Editor/Mono/Animation/GameObjectRecorder.bindings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5-
using Unity.Bindings;
65
using UnityEngine;
6+
using UnityEngine.Bindings;
77
using UnityEditor;
88
using Object = UnityEngine.Object;
99

1010
namespace UnityEditor.Experimental.Animations
1111
{
12-
[NativeInclude(Header = "Runtime/Animation/EditorCurveBinding.bindings.h")]
13-
[NativeInclude(Header = "Runtime/Animation/AnimationClip.h")]
14-
[NativeInclude(Header = "Editor/Src/Animation/GameObjectRecorder.h")]
12+
[NativeHeader("Runtime/Animation/EditorCurveBinding.bindings.h")]
13+
[NativeHeader("Runtime/Animation/AnimationClip.h")]
14+
[NativeHeader("Editor/Src/Animation/GameObjectRecorder.h")]
1515
[NativeType]
1616
public class GameObjectRecorder : Object
1717
{

Editor/Mono/Animation/MaterialAnimationUtility.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,30 +110,48 @@ static public void SetupMaterialPropertyBlock(MaterialProperty materialProp, int
110110
target.SetPropertyBlock(block);
111111
}
112112

113+
static public void TearDownMaterialPropertyBlock(Renderer target)
114+
{
115+
target.SetPropertyBlock(null);
116+
}
117+
113118
static public bool ApplyMaterialModificationToAnimationRecording(MaterialProperty materialProp, int changedMask, Renderer target, object oldValue)
114119
{
120+
bool applied = false;
115121
switch (materialProp.type)
116122
{
117123
case MaterialProperty.PropType.Color:
118124
SetupMaterialPropertyBlock(materialProp, changedMask, target);
119-
return ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color)oldValue);
125+
applied = ApplyMaterialModificationToAnimationRecording(materialProp, target, (Color)oldValue);
126+
if (!applied)
127+
TearDownMaterialPropertyBlock(target);
128+
return applied;
120129

121130
case MaterialProperty.PropType.Vector:
122131
SetupMaterialPropertyBlock(materialProp, changedMask, target);
123-
return ApplyMaterialModificationToAnimationRecording(materialProp, target, (Vector4)oldValue);
132+
applied = ApplyMaterialModificationToAnimationRecording(materialProp, target, (Vector4)oldValue);
133+
if (!applied)
134+
TearDownMaterialPropertyBlock(target);
135+
return applied;
124136

125137
case MaterialProperty.PropType.Float:
126138
case MaterialProperty.PropType.Range:
127139
SetupMaterialPropertyBlock(materialProp, changedMask, target);
128-
return ApplyMaterialModificationToAnimationRecording(materialProp, target, (float)oldValue);
140+
applied = ApplyMaterialModificationToAnimationRecording(materialProp, target, (float)oldValue);
141+
if (!applied)
142+
TearDownMaterialPropertyBlock(target);
143+
return applied;
129144

130145
case MaterialProperty.PropType.Texture:
131146
{
132147
if (MaterialProperty.IsTextureOffsetAndScaleChangedMask(changedMask))
133148
{
134149
string name = materialProp.name + "_ST";
135150
SetupMaterialPropertyBlock(materialProp, changedMask, target);
136-
return ApplyMaterialModificationToAnimationRecording(name, target, (Vector4)oldValue);
151+
applied = ApplyMaterialModificationToAnimationRecording(name, target, (Vector4)oldValue);
152+
if (!applied)
153+
TearDownMaterialPropertyBlock(target);
154+
return applied;
137155
}
138156
else
139157
return false;

Editor/Mono/Animation/TransitionPreview.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,19 @@ private void ResampleTransition(AnimatorStateTransition transition, AvatarMask l
264264
bool hasTransitioned = false;
265265
bool hasFinished = false;
266266

267+
//For transitions with exit time == 0, skip to end of clip so transition happens on first frame
268+
if (m_RefTransition.exitTime == 0)
269+
{
270+
m_AvatarPreview.Animator.CrossFade(0, 0f, 0, 0.9999f);
271+
}
267272
m_AvatarPreview.Animator.StartRecording(-1);
268273

269274
m_LeftStateWeightA = 0;
270275
m_LeftStateTimeA = 0;
271276

272277
m_AvatarPreview.Animator.Update(0.0f);
273278

279+
274280
while (!hasFinished && currentTime < maxDuration)
275281
{
276282
m_AvatarPreview.Animator.Update(stepTime);

Editor/Mono/Animation/ZoomableArea.cs

Lines changed: 1 addition & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ public static void DrawPlayhead(float x, float yMin, float yMax, float thickness
10611061
{
10621062
if (Event.current.type != EventType.Repaint)
10631063
return;
1064-
1064+
InitStyles();
10651065
float halfThickness = thickness * 0.5f;
10661066
Color lineColor = styles.playhead.normal.textColor.AlphaMultiplied(alpha);
10671067
if (thickness > 1f)
@@ -1201,160 +1201,6 @@ public TimeRulerDragMode BrowseRuler(Rect position, int id, ref float time, floa
12011201
return TimeRulerDragMode.None;
12021202
}
12031203

1204-
/* public void GridGUI ()
1205-
{
1206-
GUI.BeginGroup(drawRect);
1207-
1208-
if (Event.current.type != EventType.Repaint)
1209-
{
1210-
GUI.EndGroup();
1211-
return;
1212-
}
1213-
1214-
InitStyles ();
1215-
SetTickMarkerRanges();
1216-
1217-
Color tempCol = GUI.color;
1218-
1219-
HandleUtility.ApplyWireMaterial ();
1220-
GL.Begin (GL.LINES);
1221-
1222-
1223-
// Cache framed area rect as fetching the property takes some calculations
1224-
Rect rect = shownArea;
1225-
1226-
float lineStart, lineEnd;
1227-
// Draw time markers of various strengths
1228-
hTicks.SetTickStrengths(settings.hTickStyle.distMin, settings.hTickStyle.distFull, false);
1229-
if (settings.hTickStyle.stubs)
1230-
{
1231-
lineStart = rect.yMin;
1232-
lineEnd = rect.yMin - 40 / scale.y;
1233-
}
1234-
else
1235-
{
1236-
lineStart = Mathf.Max(rect.yMin, vRangeMin);
1237-
lineEnd = Mathf.Min(rect.yMax, vRangeMax);
1238-
}
1239-
for (int l=0; l<hTicks.tickLevels; l++)
1240-
{
1241-
float strength = hTicks.GetStrengthOfLevel(l);
1242-
GL.Color (settings.hTickStyle.color * new Color(1,1,1,strength) * new Color (1, 1, 1, 0.75f));
1243-
float[] ticks = hTicks.GetTicksAtLevel(l, true);
1244-
for (int j=0; j<ticks.Length; j++)
1245-
if (ticks[j] > hRangeMin && ticks[j] < hRangeMax)
1246-
DrawLine(new Vector2 (ticks[j], lineStart), new Vector2 (ticks[j], lineEnd));
1247-
}
1248-
// Draw bounds of allowed range
1249-
GL.Color (settings.hTickStyle.color * new Color(1,1,1,1) * new Color (1, 1, 1, 0.75f));
1250-
if (hRangeMin != Mathf.NegativeInfinity)
1251-
DrawLine(new Vector2 (hRangeMin, lineStart), new Vector2 (hRangeMin, lineEnd));
1252-
if (hRangeMax != Mathf.Infinity)
1253-
DrawLine(new Vector2 (hRangeMax, lineStart), new Vector2 (hRangeMax, lineEnd));
1254-
1255-
// Draw value markers of various strengths
1256-
vTicks.SetTickStrengths(settings.vTickStyle.distMin, settings.vTickStyle.distFull, false);
1257-
if (settings.vTickStyle.stubs)
1258-
{
1259-
lineStart = rect.xMin;
1260-
lineEnd = rect.xMin + 40 / scale.x;
1261-
}
1262-
else
1263-
{
1264-
lineStart = Mathf.Max(rect.xMin, hRangeMin);
1265-
lineEnd = Mathf.Min(rect.xMax, hRangeMax);
1266-
}
1267-
for (int l=0; l<vTicks.tickLevels; l++)
1268-
{
1269-
float strength = vTicks.GetStrengthOfLevel(l);
1270-
GL.Color (settings.vTickStyle.color * new Color(1,1,1,strength) * new Color (1, 1, 1, 0.75f));
1271-
float[] ticks = vTicks.GetTicksAtLevel(l, true);
1272-
for (int j=0; j<ticks.Length; j++)
1273-
if (ticks[j] > vRangeMin && ticks[j] < vRangeMax)
1274-
DrawLine(new Vector2 (lineStart, ticks[j]), new Vector2 (lineEnd, ticks[j]));
1275-
}
1276-
// Draw bounds of allowed range
1277-
GL.Color (settings.vTickStyle.color * new Color(1,1,1,1) * new Color (1, 1, 1, 0.75f));
1278-
if (vRangeMin != Mathf.NegativeInfinity)
1279-
DrawLine(new Vector2 (lineStart, vRangeMin), new Vector2 (lineEnd, vRangeMin));
1280-
if (vRangeMax != Mathf.Infinity)
1281-
DrawLine(new Vector2 (lineStart, vRangeMax), new Vector2 (lineEnd, vRangeMax));
1282-
1283-
GL.End ();
1284-
1285-
if (settings.hTickStyle.distLabel > 0)
1286-
{
1287-
// Draw time labels
1288-
GUI.color = settings.hTickStyle.labelColor;
1289-
int labelLevel = hTicks.GetLevelWithMinSeparation(settings.hTickStyle.distLabel);
1290-
1291-
// Calculate how many decimals are needed to show the differences between the labeled ticks
1292-
int decimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(hTicks.GetPeriodOfLevel(labelLevel));
1293-
1294-
// now draw
1295-
float[] ticks = hTicks.GetTicksAtLevel(labelLevel, false);
1296-
float vpos = Mathf.Floor(drawRect.height);
1297-
for (int i=0; i<ticks.Length; i++)
1298-
{
1299-
if (ticks[i] < hRangeMin || ticks[i] > hRangeMax)
1300-
continue;
1301-
Vector2 pos = DrawingToViewTransformPoint(new Vector2 (ticks[i], 0));
1302-
// Important to take floor of positions of GUI stuff to get pixel correct alignment of
1303-
// stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
1304-
pos = new Vector2(Mathf.Floor(pos.x), vpos);
1305-
GUI.Label(new Rect(pos.x-50+22, pos.y-16 - settings.hTickLabelOffset, 50, 16), ticks[i].ToString("n"+decimals)+settings.hTickStyle.unit, styles.labelTickMarks);
1306-
}
1307-
}
1308-
1309-
if (settings.vTickStyle.distLabel > 0)
1310-
{
1311-
// Draw value labels
1312-
GUI.color = settings.vTickStyle.labelColor;
1313-
int labelLevel = vTicks.GetLevelWithMinSeparation(settings.vTickStyle.distLabel);
1314-
1315-
float[] ticks = vTicks.GetTicksAtLevel(labelLevel, false);
1316-
1317-
// Calculate how many decimals are needed to show the differences between the labeled ticks
1318-
int decimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(vTicks.GetPeriodOfLevel(labelLevel));
1319-
1320-
// Calculate the size of the biggest shown label
1321-
float labelSize = 35;
1322-
if (!settings.vTickStyle.stubs && ticks.Length > 1)
1323-
{
1324-
string minNumber = ticks[1 ].ToString("n"+decimals)+settings.vTickStyle.unit;
1325-
string maxNumber = ticks[ticks.Length-2].ToString("n"+decimals)+settings.vTickStyle.unit;
1326-
labelSize = Mathf.Max(
1327-
styles.labelTickMarks.CalcSize(new GUIContent(minNumber)).x,
1328-
styles.labelTickMarks.CalcSize(new GUIContent(maxNumber)).x
1329-
) + 6;
1330-
}
1331-
1332-
// now draw
1333-
for (int i=0; i<ticks.Length; i++)
1334-
{
1335-
if (ticks[i] < vRangeMin || ticks[i] > vRangeMax)
1336-
continue;
1337-
Vector2 pos = DrawingToViewTransformPoint(new Vector2 (0, ticks[i]));
1338-
// Important to take floor of positions of GUI stuff to get pixel correct alignment of
1339-
// stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
1340-
pos = new Vector2(25, Mathf.Floor(pos.y));
1341-
GUI.Label(new Rect(pos.x, pos.y, labelSize, 16), ticks[i].ToString("n"+decimals)+settings.vTickStyle.unit, styles.labelTickMarks);
1342-
}
1343-
}
1344-
1345-
GUI.color = tempCol;
1346-
1347-
GUI.EndGroup();
1348-
}
1349-
*/
1350-
1351-
// FIXME remove when grid drawing function has been properly rewritten
1352-
void DrawLine(Vector2 lhs, Vector2 rhs)
1353-
{
1354-
GL.Vertex(DrawingToViewTransformPoint(new Vector3(lhs.x, lhs.y, 0)));
1355-
GL.Vertex(DrawingToViewTransformPoint(new Vector3(rhs.x, rhs.y, 0)));
1356-
}
1357-
13581204
private float FrameToPixel(float i, float frameRate, Rect rect, Rect theShownArea)
13591205
{
13601206
return (i - theShownArea.xMin * frameRate) * rect.width / (theShownArea.width * frameRate);

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public enum DrawCameraMode
6363
BakedTexelValidity = 28,
6464
BakedIndices = 29,
6565
BakedCharting = 30,
66+
67+
SpriteMask = 31,
6668
}
6769

6870
internal class SceneRenderModeWindow : PopupWindowContent
@@ -96,6 +98,7 @@ class Styles
9698
DrawCameraMode.AlphaChannel,
9799
DrawCameraMode.Overdraw,
98100
DrawCameraMode.Mipmaps,
101+
DrawCameraMode.SpriteMask,
99102

100103
// Deferred
101104
DrawCameraMode.DeferredDiffuse,
@@ -166,6 +169,7 @@ class Styles
166169
EditorGUIUtility.TextContent("Texel Validity"),
167170
EditorGUIUtility.TextContent("Lightmap Indices"),
168171
EditorGUIUtility.TextContent("UV Charts"),
172+
EditorGUIUtility.TextContent("Sprite Mask"),
169173
};
170174
}
171175

0 commit comments

Comments
 (0)