Skip to content

Commit b88328c

Browse files
author
Unity Technologies
committed
Unity 2022.1.0a7 C# reference source code
1 parent d81d0a5 commit b88328c

File tree

672 files changed

+20662
-11007
lines changed

Some content is hidden

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

672 files changed

+20662
-11007
lines changed

Editor/IncrementalBuildPipeline/BeeBuildProgramCommon.Data/Data.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public class PackageInfo
88
{
99
public string Name;
1010
public string ResolvedPath;
11-
public bool Immutable;
1211
}
1312

1413
public class ConfigurationData

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class PlayerBuildConfig
3535
public bool GenerateIdeProject;
3636
public bool Development;
3737
public Services Services;
38+
public string[] ManagedAssemblies;
3839
public StreamingAssetsFile[] StreamingAssetsFiles;
3940
}
4041

@@ -47,7 +48,6 @@ public class LinkerConfig
4748
{
4849
public string[] LinkXmlFiles = new string[0];
4950
public string[] AssembliesToProcess = new string[0];
50-
public string[] SearchDirectories = new string[0];
5151
public string EditorToLinkerData;
5252
public string Runtime;
5353
public string Profile;

Editor/IncrementalBuildPipeline/ScriptCompilationBuildProgram.Data/Data.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace ScriptCompilationBuildProgram.Data
77
public static class Constants
88
{
99
public const string ScriptAssembliesTarget = "ScriptAssemblies";
10+
public const string ScriptAssembliesAndTypeDBTarget = "ScriptAssembliesAndTypeDB";
1011
public const string MovedFromExtension = "mvfrm";
1112
}
1213

@@ -21,6 +22,11 @@ public class ScriptCompilationData
2122
public bool Debug;
2223
public string BuildTarget;
2324
public string Localization;
25+
public string BuildPlayerDataOutput;
26+
public bool ExtractRuntimeInitializeOnLoads;
27+
public bool EnableDiagnostics;
28+
public string[] AssembliesToScanForTypeDB;
29+
public string[] SearchPaths;
2430
}
2531

2632
public class AssemblyData
@@ -34,6 +40,7 @@ public class AssemblyData
3440
public string RuleSet;
3541
public string LanguageVersion;
3642
public bool UseDeterministicCompilation;
43+
public bool SuppressCompilerWarnings;
3744
public string[] Analyzers = new string[0];
3845
public string Asmdef;
3946
public string[] BclDirectories = new string[0];

Editor/Mono/2D/SpriteAtlas/EditorSpriteAtlas.bindings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ namespace UnityEditor.U2D
1313
[NativeHeader("Editor/Src/2D/SpriteAtlas/SpriteAtlasPackingUtilities.h")]
1414
public class SpriteAtlasUtility
1515
{
16+
[FreeFunction("SpriteAtlasExtensions::EnableV2Import")]
17+
extern internal static void EnableV2Import(bool onOff);
18+
19+
[FreeFunction("SpriteAtlasExtensions::CleanupAtlasPacking")]
20+
extern public static void CleanupAtlasPacking();
21+
1622
[FreeFunction("CollectAllSpriteAtlasesAndPack")]
1723
extern public static void PackAllAtlases(BuildTarget target, bool canCancel = true);
1824

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,9 @@ protected void ApplyRevertGUI()
405405
if (GUILayout.Button("Pack Preview"))
406406
{
407407
GUI.FocusControl(null);
408+
SpriteAtlasUtility.EnableV2Import(true);
408409
ApplyAndImport();
410+
SpriteAtlasUtility.EnableV2Import(false);
409411
m_HasChanged = false;
410412
}
411413
}

Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ private AnimationClip[] GetOrderedClipList()
214214
if (state.activeRootGameObject != null)
215215
clips = AnimationUtility.GetAnimationClips(state.activeRootGameObject);
216216

217-
Array.Sort(clips, (AnimationClip clip1, AnimationClip clip2) => CurveUtility.GetClipName(clip1).CompareTo(CurveUtility.GetClipName(clip2)));
217+
//Using AlphaNum/Natural Compare to sort clips
218+
Array.Sort(clips, (AnimationClip clip1, AnimationClip clip2) => EditorUtility.NaturalCompareObjectNames(clip1, clip2));
218219

219220
return clips;
220221
}

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ internal static AnimationClip CreateNewClipAtPath(string clipPath)
10261026

10271027
if (asset)
10281028
{
1029+
newClip.name = asset.name;
10291030
EditorUtility.CopySerialized(newClip, asset);
10301031
AssetDatabase.SaveAssets();
10311032
Object.DestroyImmediate(newClip);

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public enum NormalizationMode
4343
GUIContent m_GUIContent = new GUIContent();
4444

4545
[SerializeField]
46-
GUIView delegateView;
46+
GUIView m_DelegateView;
47+
internal GUIView delegateView => m_DelegateView;
4748

4849
public const string CurveChangedCommand = "CurveChanged";
4950
public const string CurveChangeCompletedCommand = "CurveChangeCompleted";
@@ -269,7 +270,7 @@ private void RefreshShownCurves()
269270

270271
public void Show(GUIView viewToUpdate, CurveEditorSettings settings)
271272
{
272-
delegateView = viewToUpdate;
273+
m_DelegateView = viewToUpdate;
273274
m_OnCurveChanged = null;
274275

275276
Init(settings);
@@ -281,7 +282,7 @@ public void Show(GUIView viewToUpdate, CurveEditorSettings settings)
281282
public void Show(Action<AnimationCurve> onCurveChanged, CurveEditorSettings settings)
282283
{
283284
m_OnCurveChanged = onCurveChanged;
284-
delegateView = null;
285+
m_DelegateView = null;
285286

286287
Init(settings);
287288
ShowAuxWindow();
@@ -451,7 +452,7 @@ void OnGUI()
451452
{
452453
bool gotMouseUp = (Event.current.type == EventType.MouseUp);
453454

454-
if (delegateView == null && m_OnCurveChanged == null)
455+
if (m_DelegateView == null && m_OnCurveChanged == null)
455456
m_Curve = null;
456457

457458
if (ms_Styles == null)
@@ -576,11 +577,11 @@ private void DoUpdateCurve(bool exitGUI)
576577

577578
void SendEvent(string eventName, bool exitGUI)
578579
{
579-
if (delegateView)
580+
if (m_DelegateView)
580581
{
581582
Event e = EditorGUIUtility.CommandEvent(eventName);
582583
Repaint();
583-
delegateView.SendEvent(e);
584+
m_DelegateView.SendEvent(e);
584585
if (exitGUI)
585586
GUIUtility.ExitGUI();
586587
}

Editor/Mono/Annotation/AnnotationUtility.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ internal sealed partial class AnnotationUtility
7272

7373
[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]
7474
internal extern static float fadeGizmoSize { get; set; }
75+
7576
[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]
7677
internal extern static bool fadeGizmos { get; set; }
78+
79+
[StaticAccessor("GetAnnotationManager()", StaticAccessorType.Dot)]
80+
internal extern static bool useInspectorExpandedState { get; set; }
7781
}
7882
}

Editor/Mono/AssemblyHelper.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using UnityEditor.VisualStudioIntegration;
1818
using UnityEngine.Scripting;
1919
using Debug = UnityEngine.Debug;
20+
using Unity.Profiling;
2021

2122
namespace UnityEditor
2223
{
@@ -420,5 +421,79 @@ internal static ICollection<string> FindAssemblies(string basePath, int maxDepth
420421

421422
return assemblies;
422423
}
424+
425+
/// <summary>
426+
/// Performs a depth-first-search topological sort on the input assemblies,
427+
/// based on the outgoing assembly references from each assembly. The
428+
/// returned list is sorted such that assembly A appears before any
429+
/// assemblies that depend (directly or indirectly) on assembly A.
430+
/// </summary>
431+
internal static Assembly[] TopologicalSort(Assembly[] assemblies)
432+
{
433+
using var _ = new ProfilerMarker("SortAssembliesTopologically").Auto();
434+
435+
var assembliesByName = new Dictionary<string, int>(assemblies.Length);
436+
for (var i = 0; i < assemblies.Length; i++)
437+
{
438+
assembliesByName[assemblies[i].GetName().Name] = i;
439+
}
440+
441+
var result = new Assembly[assemblies.Length];
442+
var resultIndex = 0;
443+
444+
var visited = new TopologicalSortVisitStatus[assemblies.Length];
445+
446+
void VisitAssembly(int index)
447+
{
448+
var visitStatus = visited[index];
449+
450+
switch (visitStatus)
451+
{
452+
case TopologicalSortVisitStatus.Visiting:
453+
// We have a cyclic dependency between assemblies. This should really be an error, but...
454+
// We need to allow cyclic dependencies between assemblies, because the rest of Unity allows them.
455+
// For example if you make an assembly override for UnityEngine.AccessibilityModule.dll,
456+
// it will reference UnityEditor.CoreModule.dll, which in turn references
457+
// UnityEngine.AccessibilityModule.dll... and that doesn't trigger an error.
458+
// The topological sort won't be correct in this case, but it's better than erroring-out.
459+
break;
460+
461+
case TopologicalSortVisitStatus.NotVisited:
462+
visited[index] = TopologicalSortVisitStatus.Visiting;
463+
464+
var assembly = assemblies[index];
465+
466+
var assemblyReferences = assembly.GetReferencedAssemblies();
467+
foreach (var assemblyReference in assemblyReferences)
468+
{
469+
// It's okay if we can't resolve the assembly. It just means that the referenced assembly
470+
// is not in the input set of assemblies, so we wouldn't be able to sort it anyway.
471+
if (assembliesByName.TryGetValue(assemblyReference.Name, out var referencedAssembly))
472+
{
473+
VisitAssembly(referencedAssembly);
474+
}
475+
}
476+
477+
visited[index] = TopologicalSortVisitStatus.Visited;
478+
479+
result[resultIndex++] = assembly;
480+
break;
481+
}
482+
}
483+
484+
for (var i = 0; i < assemblies.Length; i++)
485+
{
486+
VisitAssembly(i);
487+
}
488+
489+
return result;
490+
}
491+
492+
private enum TopologicalSortVisitStatus : byte
493+
{
494+
NotVisited,
495+
Visiting,
496+
Visited
497+
}
423498
}
424499
}

0 commit comments

Comments
 (0)