Skip to content

Commit 053d3ce

Browse files
author
Unity Technologies
committed
Unity 2019.3.0a3 C# reference source code
1 parent eb7074d commit 053d3ce

281 files changed

Lines changed: 5838 additions & 2066 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/Common/SpriteEditorUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public static void FourIntFields(Vector2 rectSize, GUIContent label, GUIContent
167167
fieldRect.width -= EditorGUI.kSpacingSubLabel;
168168

169169
float oldLabelWidth = EditorGUIUtility.labelWidth;
170-
EditorGUIUtility.labelWidth = EditorGUI.kMiniLabelW;
170+
EditorGUIUtility.labelWidth = EditorGUI.CalcPrefixLabelWidth(labelX);
171171

172172
GUI.SetNextControlName("FourIntFields_x");
173173
x = EditorGUI.IntField(fieldRect, labelX, x);

Editor/Mono/Animation/AnimationWindow/AnimEditor.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,16 @@ static private Color filterBySelectionColor
9595
}
9696

9797
internal const int kSliderThickness = 15;
98-
internal const int kLayoutRowHeight = EditorGUI.kWindowToolbarHeight + 1;
9998
internal const int kIntFieldWidth = 35;
10099
internal const int kHierarchyMinWidth = 300;
101100
internal const int kToggleButtonWidth = 80;
102101
internal const float kDisabledRulerAlpha = 0.12f;
103102

103+
private int layoutRowHeight
104+
{
105+
get { return (int)EditorGUI.kWindowToolbarHeight + 1; }
106+
}
107+
104108
internal struct FrameRateMenuEntry
105109
{
106110
public FrameRateMenuEntry(GUIContent content, float value)
@@ -205,12 +209,12 @@ public void OnAnimEditorGUI(EditorWindow parent, Rect position)
205209
GUILayout.BeginVertical();
206210

207211
// First row of controls
208-
GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
212+
GUILayout.BeginHorizontal(AnimationWindowStyles.animPlayToolBar);
209213
PlayControlsOnGUI();
210214
GUILayout.EndHorizontal();
211215

212216
// Second row of controls
213-
GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
217+
GUILayout.BeginHorizontal(AnimationWindowStyles.animClipToolBar);
214218
LinkOptionsOnGUI();
215219
ClipSelectionDropDownOnGUI();
216220
GUILayout.FlexibleSpace();
@@ -233,8 +237,8 @@ public void OnAnimEditorGUI(EditorWindow parent, Rect position)
233237
GUILayout.BeginVertical();
234238

235239
// Acquire Rects
236-
Rect timerulerRect = GUILayoutUtility.GetRect(contentWidth, kLayoutRowHeight);
237-
Rect eventsRect = GUILayoutUtility.GetRect(contentWidth, kLayoutRowHeight);
240+
Rect timerulerRect = GUILayoutUtility.GetRect(contentWidth, layoutRowHeight);
241+
Rect eventsRect = GUILayoutUtility.GetRect(contentWidth, layoutRowHeight - 1);
238242
Rect contentLayoutRect = GUILayoutUtility.GetRect(contentWidth, contentWidth, 0f, float.MaxValue, GUILayout.ExpandHeight(true));
239243

240244
// MainContent must be done first since it resizes the Zoomable area.
@@ -567,7 +571,7 @@ private void FrameRateInputFieldOnGUI()
567571

568572
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
569573
{
570-
GUILayout.Label(AnimationWindowStyles.samples, AnimationWindowStyles.toolbarLabel);
574+
GUILayout.Label(AnimationWindowStyles.samples, EditorStyles.miniLabel);
571575

572576
EditorGUI.BeginChangeCheck();
573577
int clipFrameRate = EditorGUILayout.DelayedIntField((int)m_State.clipFrameRate, EditorStyles.toolbarTextField, GUILayout.Width(kIntFieldWidth));
@@ -660,8 +664,10 @@ private void CurveEditorOnGUI(Rect position)
660664
private void TimeRulerOnGUI(Rect timeRulerRect)
661665
{
662666
Rect timeRulerRectNoScrollbar = new Rect(timeRulerRect.xMin, timeRulerRect.yMin, timeRulerRect.width - kSliderThickness, timeRulerRect.height);
667+
Rect timeRulerBackgroundRect = timeRulerRectNoScrollbar;
663668

664-
GUI.Box(timeRulerRect, GUIContent.none, EditorStyles.toolbarButton);
669+
timeRulerBackgroundRect.y += 2;
670+
GUI.Box(timeRulerBackgroundRect, GUIContent.none, AnimationWindowStyles.timeRulerBackground);
665671

666672
if (!m_State.disabled)
667673
{
@@ -711,7 +717,7 @@ private GenericMenu GenerateOptionsMenu()
711717

712718
private void OptionsOnGUI(int controlID)
713719
{
714-
Rect layoutRect = new Rect(hierarchyWidth - 1f, -1f, contentWidth, kLayoutRowHeight);
720+
Rect layoutRect = new Rect(hierarchyWidth - 1f, 1f, contentWidth, layoutRowHeight);
715721

716722
GUI.BeginGroup(layoutRect);
717723

@@ -758,7 +764,7 @@ private void AddEventButtonOnGUI()
758764
{
759765
using (new EditorGUI.DisabledScope(!selection.animationIsEditable))
760766
{
761-
if (GUILayout.Button(AnimationWindowStyles.addEventContent, EditorStyles.toolbarButton))
767+
if (GUILayout.Button(AnimationWindowStyles.addEventContent, AnimationWindowStyles.animClipToolbarButton))
762768
m_Events.AddEvent(m_State.currentTime, selection.rootGameObject, selection.animationClip);
763769
}
764770
}
@@ -768,7 +774,7 @@ private void AddKeyframeButtonOnGUI()
768774
bool canAddKey = selection.animationIsEditable && m_State.allCurves.Count != 0;
769775
using (new EditorGUI.DisabledScope(!canAddKey))
770776
{
771-
if (GUILayout.Button(AnimationWindowStyles.addKeyframeContent, EditorStyles.toolbarButton))
777+
if (GUILayout.Button(AnimationWindowStyles.addKeyframeContent, AnimationWindowStyles.animClipToolbarButton))
772778
{
773779
SaveCurveEditorKeySelection();
774780
var keyTime = AnimationKeyTime.Time(m_State.currentTime, m_State.frameRate);

Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public void OnGUI()
171171
if (state.selection.canChangeAnimationClip)
172172
{
173173
EditorGUI.BeginChangeCheck();
174-
var newClip = DoClipPopup(state.activeAnimationClip, EditorStyles.toolbarPopup);
174+
var newClip = DoClipPopup(state.activeAnimationClip, AnimationWindowStyles.animClipToolbarPopup);
175175
if (EditorGUI.EndChangeCheck())
176176
{
177177
state.activeAnimationClip = newClip;

Editor/Mono/Animation/AnimationWindow/AnimationWindowHierarchyGUI.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ internal class AnimationWindowHierarchyGUI : TreeViewGUI
2020
private GUIStyle m_AnimationRowEvenStyle;
2121
private GUIStyle m_AnimationRowOddStyle;
2222
private GUIStyle m_AnimationSelectionTextField;
23-
private GUIStyle m_AnimationLineStyle;
2423
private GUIStyle m_AnimationCurveDropdown;
24+
private bool m_StyleInitialized;
2525
private AnimationWindowHierarchyNode m_RenamedNode;
2626
private Color m_LightSkinPropertyTextColor = new Color(.35f, .35f, .35f);
2727
private Color m_PhantomCurveColor = new Color(0f, 153f / 255f, 153f / 255f);
@@ -56,19 +56,19 @@ public AnimationWindowHierarchyGUI(TreeViewController treeView, AnimationWindowS
5656

5757
protected void InitStyles()
5858
{
59-
if (m_AnimationRowEvenStyle == null)
59+
if (!m_StyleInitialized)
60+
{
6061
m_AnimationRowEvenStyle = "AnimationRowEven";
61-
if (m_AnimationRowOddStyle == null)
6262
m_AnimationRowOddStyle = "AnimationRowOdd";
63-
if (m_AnimationSelectionTextField == null)
6463
m_AnimationSelectionTextField = "AnimationSelectionTextField";
65-
if (m_AnimationLineStyle == null)
66-
{
67-
m_AnimationLineStyle = Styles.lineStyle;
68-
m_AnimationLineStyle.padding.left = 0;
69-
}
70-
if (m_AnimationCurveDropdown == null)
64+
65+
lineStyle = Styles.lineStyle;
66+
lineStyle.padding.left = 0;
67+
7168
m_AnimationCurveDropdown = "AnimPropDropdown";
69+
70+
m_StyleInitialized = true;
71+
}
7272
}
7373

7474
protected void DoNodeGUI(Rect rect, AnimationWindowHierarchyNode node, bool selected, bool focused, int row)
@@ -190,9 +190,9 @@ private void DoFoldout(AnimationWindowHierarchyNode node, Rect rect, float inden
190190
{
191191
Rect toggleRect = rect;
192192
toggleRect.x = indent;
193-
toggleRect.width = Styles.foldoutWidth;
193+
toggleRect.width = foldoutStyleWidth;
194194
EditorGUI.BeginChangeCheck();
195-
bool newExpandedValue = GUI.Toggle(toggleRect, m_HierarchyItemFoldControlIDs[row], m_TreeView.data.IsExpanded(node), GUIContent.none, Styles.foldout);
195+
bool newExpandedValue = GUI.Toggle(toggleRect, m_HierarchyItemFoldControlIDs[row], m_TreeView.data.IsExpanded(node), GUIContent.none, foldoutStyle);
196196
if (EditorGUI.EndChangeCheck())
197197
{
198198
if (Event.current.alt)
@@ -210,11 +210,11 @@ private void DoFoldout(AnimationWindowHierarchyNode node, Rect rect, float inden
210210
{
211211
Rect toggleRect = rect;
212212
toggleRect.x = indent;
213-
toggleRect.width = Styles.foldoutWidth;
213+
toggleRect.width = foldoutStyleWidth;
214214

215215
EditorGUI.BeginChangeCheck();
216216
bool tallMode = hierarchyState.GetTallMode(hierarchyPropertyNode);
217-
tallMode = GUI.Toggle(toggleRect, m_HierarchyItemFoldControlIDs[row], tallMode, GUIContent.none, Styles.foldout);
217+
tallMode = GUI.Toggle(toggleRect, m_HierarchyItemFoldControlIDs[row], tallMode, GUIContent.none, foldoutStyle);
218218
if (EditorGUI.EndChangeCheck())
219219
hierarchyState.SetTallMode(hierarchyPropertyNode, tallMode);
220220
}
@@ -229,7 +229,7 @@ private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool se
229229
if (Event.current.type == EventType.Repaint)
230230
{
231231
if (selected)
232-
Styles.selectionStyle.Draw(rect, false, false, true, focused);
232+
selectionStyle.Draw(rect, false, false, true, focused);
233233

234234
// Leave some space for the value field that comes after.
235235
if (node is AnimationWindowHierarchyPropertyNode)
@@ -257,7 +257,7 @@ private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool se
257257
tooltipText = "Target for curve is ambiguous since there are multiple GameObjects with same name (" + node.path + ")";
258258
}
259259

260-
Color oldColor = m_AnimationLineStyle.normal.textColor;
260+
Color oldColor = lineStyle.normal.textColor;
261261
Color textColor = oldColor;
262262
if (node.depth == 0)
263263
{
@@ -283,12 +283,12 @@ private void DoIconAndName(Rect rect, AnimationWindowHierarchyNode node, bool se
283283
textColor = isPhantom ? phantomColor : textColor;
284284
}
285285
textColor = isLeftOverCurve || isAmbiguous ? k_LeftoverCurveColor : textColor;
286-
SetStyleTextColor(m_AnimationLineStyle, textColor);
286+
SetStyleTextColor(lineStyle, textColor);
287287

288-
rect.xMin += (int)(indent + Styles.foldoutWidth + m_AnimationLineStyle.margin.left);
289-
GUI.Label(rect, Styles.content, m_AnimationLineStyle);
288+
rect.xMin += (int)(indent + foldoutStyleWidth + lineStyle.margin.left);
289+
GUI.Label(rect, Styles.content, lineStyle);
290290

291-
SetStyleTextColor(m_AnimationLineStyle, oldColor);
291+
SetStyleTextColor(lineStyle, oldColor);
292292
}
293293

294294
if (IsRenaming(node.id) && Event.current.type != EventType.Layout)

Editor/Mono/Animation/AnimationWindow/AnimationWindowStyles.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ internal class AnimationWindowStyles
4242

4343
public static GUIStyle playHead = "AnimationPlayHead";
4444

45+
public static GUIStyle animPlayToolBar = "AnimPlayToolbar";
46+
public static GUIStyle animClipToolBar = "AnimClipToolbar";
47+
public static GUIStyle animClipToolbarButton = "AnimClipToolbarButton";
48+
public static GUIStyle animClipToolbarPopup = "AnimClipToolbarPopup";
49+
public static GUIStyle timeRulerBackground = "TimeRulerBackground";
4550
public static GUIStyle curveEditorBackground = "CurveEditorBackground";
4651
public static GUIStyle curveEditorLabelTickmarks = "CurveEditorLabelTickmarks";
4752
public static GUIStyle eventBackground = "AnimationEventBackground";
@@ -56,15 +61,13 @@ internal class AnimationWindowStyles
5661
public static GUIStyle popupCurveEditorSwatch = "PopupCurveEditorSwatch";
5762
public static GUIStyle popupCurveSwatchBackground = "PopupCurveSwatchBackground";
5863

59-
public static GUIStyle miniToolbar = EditorStyles.toolbar;
64+
public static GUIStyle miniToolbar = "PreToolbar";
6065
public static GUIStyle miniToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
61-
public static GUIStyle toolbarLabel = new GUIStyle(EditorStyles.toolbarPopup);
66+
public static GUIStyle toolbarLabel = new GUIStyle(AnimationWindowStyles.animClipToolbarPopup);
6267

6368
public static void Initialize()
6469
{
6570
toolbarLabel.normal.background = null;
66-
miniToolbarButton.padding.top = 0;
67-
miniToolbarButton.padding.bottom = 3;
6871
}
6972
}
7073
}

Editor/Mono/Animation/AnimationWindow/Deprecated/EditorGUIExt.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ public static void MinMaxSlider(Rect position, ref float value, ref float size,
194194
DoMinMaxSlider(position, GUIUtility.GetControlID(s_MinMaxSliderHash, FocusType.Passive), ref value, ref size, visualStart, visualEnd, startLimit, endLimit, slider, thumb, horiz);
195195
}
196196

197+
private static float ThumbSize(bool horiz, GUIStyle thumb)
198+
{
199+
if (horiz)
200+
return thumb.fixedWidth != 0 ? thumb.fixedWidth : thumb.padding.horizontal;
201+
return thumb.fixedHeight != 0 ? thumb.fixedHeight : thumb.padding.vertical;
202+
}
203+
197204
internal static void DoMinMaxSlider(Rect position, int id, ref float value, ref float size, float visualStart, float visualEnd, float startLimit, float endLimit, GUIStyle slider, GUIStyle thumb, bool horiz)
198205
{
199206
Event evt = Event.current;
@@ -230,27 +237,32 @@ internal static void DoMinMaxSlider(Rect position, int id, ref float value, ref
230237
float mousePosition;
231238
Rect thumbRect;
232239
Rect thumbMinRect, thumbMaxRect;
240+
Rect contentRect = thumb.margin.Remove(slider.padding.Remove(position));
241+
float thumbSize = ThumbSize(horiz, thumb);
242+
233243
if (horiz)
234244
{
235-
float thumbSize = thumb.fixedWidth != 0 ? thumb.fixedWidth : thumb.padding.horizontal;
245+
float thumbHeight = (thumb.fixedHeight != 0 ? thumb.fixedHeight : contentRect.height);
246+
236247
pixelsPerValue = (position.width - slider.padding.horizontal - thumbSize) / (maxVisual - minVisual);
237248
thumbRect = new Rect(
238-
(displayValue - minVisual) * pixelsPerValue + position.x + slider.padding.left,
239-
position.y + slider.padding.top,
249+
(displayValue - minVisual) * pixelsPerValue + contentRect.x,
250+
contentRect.y,
240251
displaySize * pixelsPerValue + thumbSize,
241-
position.height - slider.padding.vertical);
252+
thumbHeight);
242253
thumbMinRect = new Rect(thumbRect.x, thumbRect.y, thumb.padding.left, thumbRect.height);
243254
thumbMaxRect = new Rect(thumbRect.xMax - thumb.padding.right, thumbRect.y, thumb.padding.right, thumbRect.height);
244255
mousePosition = evt.mousePosition.x - position.x;
245256
}
246257
else
247258
{
248-
float thumbSize = thumb.fixedHeight != 0 ? thumb.fixedHeight : thumb.padding.vertical;
259+
float thumbWidth = (thumb.fixedWidth != 0 ? thumb.fixedWidth : contentRect.width);
260+
249261
pixelsPerValue = (position.height - slider.padding.vertical - thumbSize) / (maxVisual - minVisual);
250262
thumbRect = new Rect(
251-
position.x + slider.padding.left,
252-
(displayValue - minVisual) * pixelsPerValue + position.y + slider.padding.top,
253-
position.width - slider.padding.horizontal,
263+
contentRect.x,
264+
(displayValue - minVisual) * pixelsPerValue + contentRect.y,
265+
thumbWidth,
254266
displaySize * pixelsPerValue + thumbSize);
255267
thumbMinRect = new Rect(thumbRect.x, thumbRect.y, thumbRect.width, thumb.padding.top);
256268
thumbMaxRect = new Rect(thumbRect.x, thumbRect.yMax - thumb.padding.bottom, thumbRect.width, thumb.padding.bottom);

Editor/Mono/Animation/TimeArea.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntir
211211

212212
float labelpos = Mathf.Floor(FrameToPixel(frame, frameRate, position));
213213
string label = FormatTickTime(m_TickCache[i], frameRate, timeFormat);
214-
GUI.Label(new Rect(labelpos + 3, -3, 40, 20), label, timeAreaStyles.timelineTick);
214+
GUI.Label(new Rect(labelpos + 3, -1, 40, 20), label, timeAreaStyles.timelineTick);
215215
}
216216
}
217217
GUI.EndGroup();

Editor/Mono/Animation/ZoomableArea.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ public Styles(bool minimalGUI)
258258
if (minimalGUI)
259259
{
260260
visualSliderWidth = 0;
261-
sliderWidth = 15;
261+
sliderWidth = 12;
262262
}
263263
else
264264
{
265-
visualSliderWidth = 15;
266-
sliderWidth = 15;
265+
visualSliderWidth = 12;
266+
sliderWidth = 12;
267267
}
268268
}
269269

0 commit comments

Comments
 (0)