Skip to content

Commit 222c983

Browse files
author
Unity Technologies
committed
Unity 2019.3.0a4 C# reference source code
1 parent 053d3ce commit 222c983

125 files changed

Lines changed: 2111 additions & 1475 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/AssemblyHelper.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -482,24 +482,6 @@ internal static Type[] GetTypesFromAssembly(Assembly assembly)
482482
}
483483
}
484484

485-
internal static IEnumerable<T> FindImplementors<T>(Assembly assembly) where T : class
486-
{
487-
Type interfaze = typeof(T);
488-
foreach (Type type in AssemblyHelper.GetTypesFromAssembly(assembly))
489-
{
490-
if (/*type.IsNotPublic - future! ||*/ type.IsInterface || type.IsAbstract || !interfaze.IsAssignableFrom(type))
491-
continue;
492-
T module = null;
493-
494-
if (typeof(ScriptableObject).IsAssignableFrom(type))
495-
module = ScriptableObject.CreateInstance(type) as T;
496-
else
497-
module = Activator.CreateInstance(type) as T;
498-
if (module != null)
499-
yield return module;
500-
}
501-
}
502-
503485
public static bool IsManagedAssembly(string file)
504486
{
505487
bool isManagedDll;

Editor/Mono/AssetDatabase/AssetDatabase.bindings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public static bool TryGetGUIDAndLocalFileIdentifier(int instanceID, out string g
107107
return res;
108108
}
109109

110+
public static bool TryGetGUIDAndLocalFileIdentifier<T>(LazyLoadReference<T> assetRef, out string guid, out long localId) where T : UnityEngine.Object
111+
{
112+
GUID uguid;
113+
bool res = GetGUIDAndLocalIdentifierInFile(assetRef.instanceID, out uguid, out localId);
114+
guid = uguid.ToString();
115+
return res;
116+
}
117+
110118
public static void ForceReserializeAssets()
111119
{
112120
ForceReserializeAssets(GetAllAssetPaths());

Editor/Mono/AttributeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static MonoCreateAssetItem[] ExtractCreateAssetMenuItems(Assembly assembly)
128128
{
129129
var result = new List<MonoCreateAssetItem>();
130130

131-
foreach (var type in EditorAssemblies.GetAllTypesWithAttribute<CreateAssetMenuAttribute>())
131+
foreach (var type in TypeCache.GetTypesWithAttribute<CreateAssetMenuAttribute>())
132132
{
133133
var attr = type.GetCustomAttributes(typeof(CreateAssetMenuAttribute), false).FirstOrDefault() as CreateAssetMenuAttribute;
134134
if (attr == null)

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
internal abstract class DesktopStandalonePostProcessor : DefaultBuildPostprocessor
1818
{
1919
readonly bool m_HasIl2CppPlayers;
20+
protected const string k_MonoDirectoryName = "MonoBleedingEdge";
2021

2122
protected DesktopStandalonePostProcessor(bool hasIl2CppPlayers)
2223
{
@@ -395,13 +396,10 @@ protected static void RecordCommonFiles(BuildPostProcessArgs args, string variat
395396
CommonRoles.builtInResources);
396397

397398
// Mark up each mono runtime
398-
foreach (var monoName in new[] {"Mono", "MonoBleedingEdge"})
399-
{
400-
args.report.RecordFilesAddedRecursive(Path.Combine(monoFolderRoot, monoName + "/EmbedRuntime"),
401-
CommonRoles.monoRuntime);
402-
args.report.RecordFilesAddedRecursive(Path.Combine(monoFolderRoot, monoName + "/etc"),
403-
CommonRoles.monoConfig);
404-
}
399+
args.report.RecordFilesAddedRecursive(Path.Combine(monoFolderRoot, k_MonoDirectoryName + "/EmbedRuntime"),
400+
CommonRoles.monoRuntime);
401+
args.report.RecordFilesAddedRecursive(Path.Combine(monoFolderRoot, k_MonoDirectoryName + "/etc"),
402+
CommonRoles.monoConfig);
405403
}
406404

407405
private void CopyStagingAreaIntoBuildsFolder(BuildPostProcessArgs args)
@@ -457,19 +455,14 @@ private static void CopyFilesToDestination(string source, string target, HashSet
457455

458456
protected abstract void DeleteDestination(BuildPostProcessArgs args);
459457

460-
protected static string GetMonoFolderName(ScriptingRuntimeVersion scriptingRuntimeVersion)
461-
{
462-
return "MonoBleedingEdge";
463-
}
464-
465458
protected static bool UseMono => !UseIl2Cpp || IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildTargetGroup.Standalone);
466459

467460
protected static void DeleteUnusedMono(string dataFolder, BuildReport report)
468461
{
469462
// Mono is built by the il2cpp builder, so we dont need the libs copied
470463
if (!UseMono)
471464
{
472-
var monoPath = Path.Combine(dataFolder, GetMonoFolderName(ScriptingRuntimeVersion.Latest));
465+
var monoPath = Path.Combine(dataFolder, k_MonoDirectoryName);
473466
FileUtil.DeleteFileOrDirectory(monoPath);
474467
report.RecordFilesDeletedRecursive(monoPath);
475468
}

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ internal static string ApiCompatibilityLevelToDotNetProfileArgument(ApiCompatibi
134134

135135
internal static bool UseIl2CppCodegenWithMonoBackend(BuildTargetGroup targetGroup)
136136
{
137-
return EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest &&
138-
EditorApplication.useLibmonoBackendForIl2cpp &&
137+
return EditorApplication.useLibmonoBackendForIl2cpp &&
139138
PlayerSettings.GetScriptingBackend(targetGroup) == ScriptingImplementation.IL2CPP;
140139
}
141140

@@ -423,9 +422,7 @@ private void ConvertPlayerDlltoCpp(string inputDirectory, string outputDirectory
423422
arguments.Add("--mono-runtime");
424423

425424
// Working around gcc bug 41091
426-
if (m_PlatformProvider.target == BuildTarget.StandaloneLinux ||
427-
m_PlatformProvider.target == BuildTarget.StandaloneLinux64 ||
428-
m_PlatformProvider.target == BuildTarget.StandaloneLinuxUniversal)
425+
if (m_PlatformProvider.target == BuildTarget.StandaloneLinux64)
429426
{
430427
arguments.Add("--disable-aggressive-inlining");
431428
}

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Styles
2828
{
2929
public GUIContent invalidColorSpaceMessage = EditorGUIUtility.TrTextContent("In order to build a player, go to 'Player Settings...' to resolve the incompatibility between the Color Space and the current settings.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
3030
public GUIContent invalidLightmapEncodingMessage = EditorGUIUtility.TrTextContent("In order to build a player, go to 'Player Settings...' to resolve the incompatibility between the selected Lightmap Encoding and the current settings.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
31+
public GUIContent compilingMessage = EditorGUIUtility.TrTextContent("Cannot build player while editor is importing assets or compiling scripts.", EditorGUIUtility.GetHelpIcon(MessageType.Warning));
3132
public GUIStyle selected = "OL SelectedRow";
3233
public GUIStyle box = "OL Box";
3334
public GUIStyle title = EditorStyles.boldLabel;
@@ -862,6 +863,12 @@ private static void GUIBuildButtons(IBuildWindowExtension buildWindowExtension,
862863
EditorGUILayout.HelpBox(styles.invalidLightmapEncodingMessage);
863864
}
864865

866+
if (EditorApplication.isCompiling || EditorApplication.isUpdating)
867+
{
868+
enableBuildAndRunButton = false;
869+
enableBuildButton = false;
870+
EditorGUILayout.HelpBox(styles.compilingMessage);
871+
}
865872
GUILayout.BeginHorizontal();
866873
GUILayout.FlexibleSpace();
867874
if (EditorGUILayout.LinkLabel(styles.learnAboutUnityCloudBuild))

Editor/Mono/BuildTarget.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public enum BuildTarget
5353
// was NaCl = 16,
5454

5555
// Build a Linux standalone (i386 only).
56-
// TODO: Uncomment this attribute once HDRP plugin is updated in 2019.2.
57-
// [System.Obsolete("StandaloneLinux has been removed in 2019.2")]
56+
[System.Obsolete("StandaloneLinux has been removed in 2019.2")]
5857
StandaloneLinux = 17,
5958

6059
// Build a Windows x86_64 standalone.
@@ -70,8 +69,7 @@ public enum BuildTarget
7069
StandaloneLinux64 = 24,
7170

7271
// Build a Linux standalone (i386/x86_64 universal).
73-
// TODO: Uncomment this attribute once HDRP plugin is updated in 2019.2.
74-
// [System.Obsolete("StandaloneLinuxUniversal has been removed in 2019.2")]
72+
[System.Obsolete("StandaloneLinuxUniversal has been removed in 2019.2")]
7573
StandaloneLinuxUniversal = 25,
7674

7775
[System.Obsolete("Use WSAPlayer with Windows Phone 8.1 selected")]

Editor/Mono/CodeEditor/CodeEditor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@ static bool OnOpenAsset(int instanceID, int line, int column)
4747
}
4848

4949
var assetFilePath = Path.GetFullPath(assetPath);
50+
var assetExtension = Path.GetExtension(assetFilePath);
51+
if (string.IsNullOrEmpty(assetExtension))
52+
{
53+
return false;
54+
}
55+
5056
if (!(selected.GetType().ToString() == "UnityEditor.MonoScript" ||
5157
selected.GetType().ToString() == "UnityEngine.Shader" ||
5258
selected.GetType().ToString() == "UnityEngine.Experimental.UIElements.VisualTreeAsset" ||
5359
selected.GetType().ToString() == "UnityEngine.StyleSheets.StyleSheet" ||
54-
GetExtensionStrings().Contains(Path.GetExtension(assetFilePath).Substring(1))
60+
GetExtensionStrings().Contains(assetExtension.Substring(1))
5561
))
5662
{
5763
return false;

Editor/Mono/ConsoleWindow.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ internal void OnGUI()
522522
// Search bar
523523
GUILayout.Space(4f);
524524
SearchField(e);
525-
GUILayout.Space(4f);
526525

527526
// Flags
528527
int errorCount = 0, warningCount = 0, logCount = 0;
@@ -790,13 +789,17 @@ private void EditorGUI_HyperLinkClicked(object sender, EventArgs e)
790789
{
791790
EditorGUILayout.HyperLinkClickedEventArgs args = (EditorGUILayout.HyperLinkClickedEventArgs)e;
792791

793-
if (!args.hyperlinkInfos.ContainsKey("href"))
792+
string filePath;
793+
string lineString;
794+
if (!args.hyperlinkInfos.TryGetValue("href", out filePath) ||
795+
!args.hyperlinkInfos.TryGetValue("line", out lineString))
794796
return;
795797

796-
int line = args.hyperlinkInfos.ContainsKey("line") ? Int32.Parse(args.hyperlinkInfos["line"]) : 0;
797-
int column = -1;
798+
int line = Int32.Parse(lineString);
799+
var projectFilePath = FileUtil.GetProjectRelativePath(filePath.Replace('\\', '/'));
798800

799-
LogEntries.OpenFileOnSpecificLineAndColumn(args.hyperlinkInfos["href"], line, column);
801+
if (!String.IsNullOrEmpty(projectFilePath))
802+
LogEntries.OpenFileOnSpecificLineAndColumn(filePath, line, -1);
800803
}
801804

802805
[UsedImplicitly]

Editor/Mono/CustomEditorAttributes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ internal static void Rebuild()
122122
{
123123
kSCustomEditors.Clear();
124124
kSCustomMultiEditors.Clear();
125-
var types = EditorAssemblies.GetAllTypesWithAttribute<CustomEditor>();
125+
var types = TypeCache.GetTypesWithAttribute<CustomEditor>();
126126
foreach (var type in types)
127127
{
128128
object[] attrs = type.GetCustomAttributes(typeof(CustomEditor), false);

0 commit comments

Comments
 (0)