Skip to content

Commit 32bd3a1

Browse files
author
Unity Technologies
committed
Unity 2020.1.0a5 C# reference source code
1 parent 02d565c commit 32bd3a1

210 files changed

Lines changed: 4527 additions & 2307 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void OnEnable()
199199
m_PackableList.onRemoveCallback = RemovePackable;
200200
m_PackableList.drawElementCallback = DrawPackableElement;
201201
m_PackableList.elementHeight = EditorGUIUtility.singleLineHeight;
202-
m_PackableList.headerHeight = 0f;
202+
m_PackableList.headerHeight = 3f;
203203

204204
SyncPlatformSettings();
205205

Editor/Mono/Animation/AnimationWindow/AnimEditor.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ static private Color filterBySelectionColor
9494
}
9595
}
9696

97-
internal const int kSliderThickness = 15;
97+
internal const int kSliderThickness = 13;
9898
internal const int kIntFieldWidth = 35;
9999
internal const int kHierarchyMinWidth = 300;
100100
internal const int kToggleButtonWidth = 80;
101101
internal const float kDisabledRulerAlpha = 0.12f;
102102

103103
private int layoutRowHeight
104104
{
105-
get { return (int)EditorGUI.kWindowToolbarHeight + 1; }
105+
get { return (int)EditorGUI.kWindowToolbarHeight; }
106106
}
107107

108108
internal struct FrameRateMenuEntry
@@ -227,9 +227,10 @@ public void OnAnimEditorGUI(EditorWindow parent, Rect position)
227227
HierarchyOnGUI();
228228

229229
// Bottom row of controls
230-
GUILayout.BeginHorizontal(AnimationWindowStyles.miniToolbar);
231-
TabSelectionOnGUI();
232-
GUILayout.EndHorizontal();
230+
using (new GUILayout.HorizontalScope(AnimationWindowStyles.toolbarBottom))
231+
{
232+
TabSelectionOnGUI();
233+
}
233234

234235
GUILayout.EndVertical();
235236

@@ -254,7 +255,10 @@ public void OnAnimEditorGUI(EditorWindow parent, Rect position)
254255
OverlayOnGUI(contentLayoutRect);
255256

256257
if (Event.current.type == EventType.Repaint)
258+
{
257259
OptionsOnGUI(optionsID);
260+
AnimationWindowStyles.separator.Draw(new Rect(hierarchyWidth, 0, 1, position.height), false, false, false, false);
261+
}
258262

259263
RenderEventTooltip();
260264
}
@@ -525,7 +529,7 @@ private void TabSelectionOnGUI()
525529
GUILayout.FlexibleSpace();
526530
EditorGUI.BeginChangeCheck();
527531
GUILayout.Toggle(!m_State.showCurveEditor, AnimationWindowStyles.dopesheet, AnimationWindowStyles.miniToolbarButton, GUILayout.Width(kToggleButtonWidth));
528-
GUILayout.Toggle(m_State.showCurveEditor, AnimationWindowStyles.curves, AnimationWindowStyles.miniToolbarButton, GUILayout.Width(kToggleButtonWidth));
532+
GUILayout.Toggle(m_State.showCurveEditor, AnimationWindowStyles.curves, EditorStyles.toolbarButtonRight, GUILayout.Width(kToggleButtonWidth));
529533
if (EditorGUI.EndChangeCheck())
530534
{
531535
SwitchBetweenCurvesAndDopesheet();
@@ -666,7 +670,6 @@ private void TimeRulerOnGUI(Rect timeRulerRect)
666670
Rect timeRulerRectNoScrollbar = new Rect(timeRulerRect.xMin, timeRulerRect.yMin, timeRulerRect.width - kSliderThickness, timeRulerRect.height);
667671
Rect timeRulerBackgroundRect = timeRulerRectNoScrollbar;
668672

669-
timeRulerBackgroundRect.y += 2;
670673
GUI.Box(timeRulerBackgroundRect, GUIContent.none, AnimationWindowStyles.timeRulerBackground);
671674

672675
if (!m_State.disabled)
@@ -717,14 +720,14 @@ private GenericMenu GenerateOptionsMenu()
717720

718721
private void OptionsOnGUI(int controlID)
719722
{
720-
Rect layoutRect = new Rect(hierarchyWidth - 1f, 1f, contentWidth, layoutRowHeight);
723+
Rect layoutRect = new Rect(hierarchyWidth, 0f, contentWidth, layoutRowHeight);
721724

722725
GUI.BeginGroup(layoutRect);
723726

724-
Vector2 optionsSize = EditorStyles.toolbarButton.CalcSize(AnimationWindowStyles.optionsContent);
725-
Rect optionsRect = new Rect(layoutRect.width - optionsSize.x, 0f, optionsSize.x, optionsSize.y);
726-
727-
if (EditorGUI.DropdownButton(controlID, optionsRect, AnimationWindowStyles.optionsContent, EditorStyles.toolbarButton))
727+
Vector2 optionsSize = EditorStyles.toolbarButtonRight.CalcSize(AnimationWindowStyles.optionsContent);
728+
Rect optionsRect = new Rect(layoutRect.width - kSliderThickness, 0f, optionsSize.x, optionsSize.y);
729+
GUI.Box(optionsRect, GUIContent.none, AnimationWindowStyles.animPlayToolBar);
730+
if (EditorGUI.DropdownButton(controlID, optionsRect, AnimationWindowStyles.optionsContent, AnimationWindowStyles.optionsButton))
728731
{
729732
var menu = GenerateOptionsMenu();
730733
menu.ShowAsContext();

Editor/Mono/Animation/AnimationWindow/AnimationWindowStyles.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal class AnimationWindowStyles
3838
public static GUIContent readOnlyPropertiesLabel = EditorGUIUtility.TrTextContent("Animation Clip is Read-Only");
3939
public static GUIContent readOnlyPropertiesButton = EditorGUIUtility.TrTextContent("Show Read-Only Properties");
4040

41-
public static GUIContent optionsContent = EditorGUIUtility.IconContent("_Popup");
41+
public static GUIContent optionsContent = EditorGUIUtility.IconContent("_Menu");
4242

4343
public static GUIStyle playHead = "AnimationPlayHead";
4444

@@ -60,14 +60,19 @@ internal class AnimationWindowStyles
6060
public static GUIStyle popupCurveEditorBackground = "PopupCurveEditorBackground";
6161
public static GUIStyle popupCurveEditorSwatch = "PopupCurveEditorSwatch";
6262
public static GUIStyle popupCurveSwatchBackground = "PopupCurveSwatchBackground";
63+
public static GUIStyle separator = new GUIStyle("AnimLeftPaneSeparator");
6364

64-
public static GUIStyle miniToolbar = "PreToolbar";
65+
public static GUIStyle toolbarBottom = "ToolbarBottom";
66+
public static GUIStyle optionsButton = new GUIStyle(EditorStyles.toolbarButtonRight);
6567
public static GUIStyle miniToolbarButton = new GUIStyle(EditorStyles.toolbarButton);
6668
public static GUIStyle toolbarLabel = new GUIStyle(AnimationWindowStyles.animClipToolbarPopup);
6769

6870
public static void Initialize()
6971
{
7072
toolbarLabel.normal.background = null;
73+
optionsButton.padding = new RectOffset();
74+
optionsButton.imagePosition = ImagePosition.ImageOnly;
75+
optionsButton.contentOffset = new Vector2(-7, 0);
7176
}
7277
}
7378
}

Editor/Mono/Annotation/SceneViewCameraWindow.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public static void Init()
4646
const float kPrefixLabelWidth = 120f;
4747
const float kNearClipMin = .01f;
4848
const int k_HeaderSpacing = 2;
49+
// FOV values chosen to be the smallest and largest before extreme visual corruption
50+
const float k_MinFieldOfView = 4f;
51+
const float k_MaxFieldOfView = 160f;
4952

5053
Vector2 m_WindowSize;
5154
Vector2 m_Scroll;
@@ -118,7 +121,7 @@ void Draw(Rect rect)
118121
// fov isn't applicable in orthographic mode, and orthographic size is controlled by the user zoom
119122
using (new EditorGUI.DisabledScope(m_SceneView.orthographic))
120123
{
121-
settings.fieldOfView = EditorGUILayout.Slider(m_FieldOfView, settings.fieldOfView, 4f, 179f);
124+
settings.fieldOfView = EditorGUILayout.Slider(m_FieldOfView, settings.fieldOfView, k_MinFieldOfView, k_MaxFieldOfView);
122125
}
123126

124127
settings.dynamicClip = EditorGUILayout.Toggle(m_DynamicClip, settings.dynamicClip);
@@ -127,11 +130,7 @@ void Draw(Rect rect)
127130
{
128131
float near = settings.nearClip, far = settings.farClip;
129132
DrawClipPlanesField(EditorGUI.s_ClipingPlanesLabel, ref near, ref far, EditorGUI.kNearFarLabelsWidth);
130-
settings.nearClip = near;
131-
settings.farClip = far;
132-
settings.nearClip = Mathf.Max(kNearClipMin, settings.nearClip);
133-
if (settings.nearClip > settings.farClip)
134-
settings.farClip = settings.nearClip + kNearClipMin;
133+
settings.SetClipPlanes(near, far);
135134
}
136135

137136
settings.occlusionCulling = EditorGUILayout.Toggle(m_OcclusionCulling, settings.occlusionCulling);

Editor/Mono/AssemblyHelper.cs

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -327,44 +327,12 @@ struct GetAssemblyResolverData
327327
public string[] SearchDirs;
328328
}
329329

330-
static GetAssemblyResolverData GetAssemblyResolver(BuildTarget targetPlatform, bool isEditor, string assemblyPathName, string[] searchDirs)
331-
{
332-
var target = ModuleManager.GetTargetStringFromBuildTarget(targetPlatform);
333-
var extension = ModuleManager.GetCompilationExtension(target);
334-
var extraPaths = extension.GetCompilerExtraAssemblyPaths(isEditor, assemblyPathName);
335-
if (extraPaths != null && extraPaths.Length > 0)
336-
{
337-
var dirs = new List<string>(searchDirs);
338-
dirs.AddRange(extraPaths);
339-
searchDirs = dirs.ToArray();
340-
}
341-
342-
var assemblyResolver = extension.GetAssemblyResolver(isEditor, assemblyPathName, searchDirs);
343-
344-
return new GetAssemblyResolverData
345-
{
346-
Resolver = assemblyResolver,
347-
SearchDirs = searchDirs
348-
};
349-
}
350-
351330
/// Extract information about all types in the specified assembly, searchDirs might be used to resolve dependencies.
352331
static public AssemblyTypeInfoGenerator.ClassInfo[] ExtractAssemblyTypeInfo(BuildTarget targetPlatform, bool isEditor, string assemblyPathName, string[] searchDirs)
353332
{
354333
try
355334
{
356-
var assemblyResolverData = GetAssemblyResolver(targetPlatform, isEditor, assemblyPathName, searchDirs);
357-
358-
AssemblyTypeInfoGenerator gen;
359-
if (assemblyResolverData.Resolver == null)
360-
{
361-
gen = new AssemblyTypeInfoGenerator(assemblyPathName, assemblyResolverData.SearchDirs);
362-
}
363-
else
364-
{
365-
gen = new AssemblyTypeInfoGenerator(assemblyPathName, assemblyResolverData.Resolver);
366-
}
367-
335+
AssemblyTypeInfoGenerator gen = new AssemblyTypeInfoGenerator(assemblyPathName, searchDirs);
368336
return gen.GatherClassInfo();
369337
}
370338
catch (System.Exception ex)
@@ -426,16 +394,12 @@ public static RuntimeInitializeOnLoadMethodsData ExtractPlayerRuntimeInitializeO
426394
{
427395
try
428396
{
429-
var assemblyResolverData = GetAssemblyResolver(targetPlatform, false, assemblyPath, searchDirs);
430-
431-
if (assemblyResolverData.Resolver == null)
432-
{
433-
var resolver = new DefaultAssemblyResolver();
434-
foreach (var searchDir in searchDirs)
435-
resolver.AddSearchDirectory(searchDir);
397+
var assemblyResolverData = new GetAssemblyResolverData { SearchDirs = searchDirs, };
398+
var resolver = new DefaultAssemblyResolver();
399+
foreach (var searchDir in searchDirs)
400+
resolver.AddSearchDirectory(searchDir);
436401

437-
assemblyResolverData.Resolver = resolver;
438-
}
402+
assemblyResolverData.Resolver = resolver;
439403

440404
var assembly = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters
441405
{

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@
108108
[assembly: InternalsVisibleTo("Unity.2D.Sprite.EditorTests")]
109109
[assembly: InternalsVisibleTo("Unity.2D.Tilemap.Editor")]
110110
[assembly: InternalsVisibleTo("Unity.2D.Tilemap.EditorTests")]
111+
[assembly: InternalsVisibleTo("Unity.PackageCleanConsoleTest.Editor")]
111112

112113
[assembly: AssemblyIsEditorAssembly]

Editor/Mono/AssetDatabase/AssetDatabase.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public sealed partial class AssetDatabase
2323
// Delegate to be called when package import completes
2424
public static event ImportPackageCallback importPackageCompleted;
2525

26+
// Called when package import completes, listing the selected items
27+
public static Action<string[]> onImportPackageItemsCompleted;
28+
2629
// Delegate to be called when package import is cancelled
2730
public static event ImportPackageCallback importPackageCancelled;
2831

@@ -43,6 +46,13 @@ private static void Internal_CallImportPackageCompleted(string packageName)
4346
importPackageCompleted(packageName);
4447
}
4548

49+
[RequiredByNativeCode]
50+
private static void Internal_CallOnImportPackageItemsCompleted(string[] items)
51+
{
52+
if (onImportPackageItemsCompleted != null)
53+
onImportPackageItemsCompleted(items);
54+
}
55+
4656
[RequiredByNativeCode]
4757
private static void Internal_CallImportPackageCancelled(string packageName)
4858
{

Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ internal void DependsOnImportedAsset(string path)
8080
[NativeName("DependsOnImportedAsset")]
8181
private extern void DependsOnImportedAssetInternal(string path);
8282

83+
public void DependsOnCustomDependency(string dependency)
84+
{
85+
if (string.IsNullOrEmpty(dependency))
86+
{
87+
throw new ArgumentNullException("dependency", "Cannot add custom dependency on an empty custom dependency.");
88+
}
89+
90+
DependsOnCustomDependencyInternal(dependency);
91+
}
92+
93+
[NativeName("DependsOnCustomDependency")]
94+
private extern void DependsOnCustomDependencyInternal(string path);
95+
8396
public void LogImportError(string msg, UnityEngine.Object obj = null)
8497
{
8598
AddToLog(msg, true, obj);

Editor/Mono/Audio/Mixer/GUI/AudioMixerDrawUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static void DrawRegionBg(Rect rect, out Rect headerRect, out Rect content
182182
const float headerIndent = 2f;
183183
headerRect = new Rect(rect.x + headerIndent, rect.y, rect.width - headerIndent, kSectionHeaderHeight);
184184
contentRect = new Rect(rect.x, headerRect.yMax, rect.width, rect.height - kSectionHeaderHeight);
185-
GUI.Label(new RectOffset(1, 1, 1, 1).Add(contentRect), GUIContent.none, EditorStyles.helpBox);
185+
GUI.Label(new RectOffset(1, 1, 1, 1).Add(contentRect), GUIContent.none, EditorStyles.frameBox);
186186
}
187187

188188
public static void HeaderLabel(Rect r, GUIContent text, Texture2D icon)

Editor/Mono/Audio/Mixer/GUI/AudioMixerGroupTreeView.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ public override bool IsRenamingItemAllowed(TreeViewItem node)
152152
internal class AudioGroupTreeViewGUI : TreeViewGUI
153153
{
154154
readonly float column1Width = 20f;
155-
readonly Texture2D k_VisibleON = EditorGUIUtility.FindTexture("VisibilityOn");
155+
readonly GUIContent k_VisibleON = EditorGUIUtility.TrIconContent("animationvisibilitytoggleon");
156+
readonly GUIContent k_VisibleOFF = EditorGUIUtility.TrIconContent("animationvisibilitytoggleoff");
156157
public Action<AudioMixerTreeViewNode, bool> NodeWasToggled;
157158
public AudioMixerController m_Controller = null;
158159

@@ -206,9 +207,10 @@ override public void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool sel
206207
if (colorIndex > 0)
207208
EditorGUI.DrawRect(new Rect(rowRect.x, iconBgRect.y, 2, iconBgRect.height), AudioMixerColorCodes.GetColor(colorIndex));
208209

209-
EditorGUI.DrawRect(iconBgRect, new Color(0.5f, 0.5f, 0.5f, 0.2f));
210210
if (oldSelected)
211-
GUI.DrawTexture(iconRect, k_VisibleON);
211+
GUI.DrawTexture(iconRect, k_VisibleON.image);
212+
else
213+
GUI.DrawTexture(iconRect, k_VisibleOFF.image);
212214

213215
Rect toggleRect = new Rect(2, rowRect.y, rowRect.height, rowRect.height);
214216
if (evt.type == EventType.MouseUp && evt.button == 0 && toggleRect.Contains(evt.mousePosition))
@@ -290,7 +292,7 @@ internal class AudioMixerGroupTreeView
290292
class Styles
291293
{
292294
public GUIContent header = EditorGUIUtility.TrTextContent("Groups", "An Audio Mixer Group is used by e.g Audio Sources to modify the audio output before it reaches the Audio Listener. An Audio Mixer Group will route its output to another Audio Mixer Group if it is made a child of that group. The Master Group will route its output to the Audio Listener if it doesn't route its output into another Mixer.");
293-
public GUIContent addText = EditorGUIUtility.TrTextContent("+", "Add child group");
295+
public GUIContent addButton = EditorGUIUtility.TrIconContent("CreateAddNew", "Add child group");
294296
public Texture2D audioMixerGroupIcon = EditorGUIUtility.FindTexture(typeof(UnityEngine.Audio.AudioMixerGroup));
295297
}
296298
static Styles s_Styles;
@@ -567,7 +569,7 @@ public void OnGUI(Rect rect)
567569
AudioMixerGroupController parent = (m_Controller.CachedSelection.Count == 1) ? m_Controller.CachedSelection[0] : m_Controller.masterGroup;
568570
using (new EditorGUI.DisabledScope(EditorApplication.isPlaying))
569571
{
570-
if (GUI.Button(new Rect(headerRect.xMax - 15f, headerRect.y + 3f, 15f, 15f), s_Styles.addText, EditorStyles.label))
572+
if (GUI.Button(new Rect(headerRect.xMax - 17f, headerRect.y + 3f, 16f, 16f), s_Styles.addButton, EditorStyles.iconButton))
571573
AddAudioMixerGroup(parent);
572574
}
573575

0 commit comments

Comments
 (0)