Skip to content

Commit 9cd83fb

Browse files
author
Unity Technologies
committed
Unity 2023.1.0a21 C# reference source code
1 parent f9f7224 commit 9cd83fb

File tree

374 files changed

+10489
-4428
lines changed

Some content is hidden

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

374 files changed

+10489
-4428
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class PlayerBuildConfig
4747
public string ApplicationIdentifier;
4848
public string Architecture;
4949
public ScriptingBackend ScriptingBackend;
50+
public bool NoGUID;
5051
public bool InstallIntoBuildsFolder;
5152
public bool GenerateIdeProject;
5253
public bool Development;
@@ -60,6 +61,7 @@ public class PlayerBuildConfig
6061
public class BuiltFilesOutput
6162
{
6263
public string[] Files = new string[0];
64+
public string BootConfigArtifact;
6365
}
6466

6567
public class LinkerConfig

Editor/Mono/AssemblyHelper.cs

Lines changed: 1 addition & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
using System.Linq;
88
using System.Reflection;
99
using System.Collections.Generic;
10-
using System.Diagnostics;
1110
using Mono.Cecil;
12-
using UnityEditor.Build;
1311
using UnityEditor.Modules;
1412
using UnityEditorInternal;
1513
using UnityEngine;
1614
using System.Runtime.InteropServices;
17-
using UnityEditor.VisualStudioIntegration;
1815
using UnityEngine.Scripting;
1916
using Debug = UnityEngine.Debug;
2017
using Unity.Profiling;
@@ -24,181 +21,11 @@
2421

2522
namespace UnityEditor
2623
{
27-
internal partial class AssemblyHelper
24+
internal class AssemblyHelper
2825
{
2926
static Dictionary<string, bool> managedToDllType = new Dictionary<string, bool>();
3027
static BuildPlayerDataExtractor m_BuildPlayerDataExtractor = new BuildPlayerDataExtractor();
3128

32-
static public string[] GetNamesOfAssembliesLoadedInCurrentDomain()
33-
{
34-
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
35-
var locations = new List<string>();
36-
foreach (var a in assemblies)
37-
{
38-
try
39-
{
40-
locations.Add(a.Location);
41-
}
42-
catch (NotSupportedException)
43-
{
44-
//we have some "dynamic" assmeblies that do not have a filename
45-
}
46-
}
47-
return locations.ToArray();
48-
}
49-
50-
static public string ExtractInternalAssemblyName(string path)
51-
{
52-
try
53-
{
54-
AssemblyDefinition definition = AssemblyDefinition.ReadAssembly(path);
55-
return definition.Name.Name;
56-
}
57-
catch
58-
{
59-
return "";
60-
}
61-
}
62-
63-
static AssemblyDefinition GetAssemblyDefinitionCached(string path, Dictionary<string, AssemblyDefinition> cache)
64-
{
65-
if (cache.ContainsKey(path))
66-
return cache[path];
67-
68-
AssemblyDefinition definition = AssemblyDefinition.ReadAssembly(path);
69-
cache[path] = definition;
70-
return definition;
71-
}
72-
73-
static private bool CouldBelongToDotNetOrWindowsRuntime(string assemblyPath)
74-
{
75-
return assemblyPath.IndexOf("mscorlib.dll") != -1 ||
76-
assemblyPath.IndexOf("System.") != -1 ||
77-
assemblyPath.IndexOf("Microsoft.") != -1 ||
78-
assemblyPath.IndexOf("Windows.") != -1 ||
79-
assemblyPath.IndexOf("WinRTLegacy.dll") != -1 ||
80-
assemblyPath.IndexOf("platform.dll") != -1;
81-
}
82-
83-
static private bool IgnoreAssembly(string assemblyPath, BuildTarget target, ScriptingImplementation scriptingImplementation)
84-
{
85-
#pragma warning disable 618
86-
if (target == BuildTarget.WSAPlayer || scriptingImplementation == ScriptingImplementation.CoreCLR)
87-
{
88-
if (CouldBelongToDotNetOrWindowsRuntime(assemblyPath))
89-
return true;
90-
}
91-
else if (target == BuildTarget.XboxOne)
92-
{
93-
var profile = PlayerSettings.GetApiCompatibilityLevel(NamedBuildTarget.XboxOne);
94-
if (profile == ApiCompatibilityLevel.NET_4_6 || profile == ApiCompatibilityLevel.NET_Standard_2_0)
95-
{
96-
if (CouldBelongToDotNetOrWindowsRuntime(assemblyPath))
97-
return true;
98-
}
99-
}
100-
101-
return IsInternalAssembly(assemblyPath);
102-
}
103-
104-
static private void AddReferencedAssembliesRecurse(string assemblyPath, List<string> alreadyFoundAssemblies, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary<string, AssemblyDefinition> cache, BuildTarget target, ScriptingImplementation scriptingImplementation)
105-
{
106-
if (IgnoreAssembly(assemblyPath, target, scriptingImplementation))
107-
return;
108-
109-
if (!File.Exists(assemblyPath))
110-
return;
111-
112-
AssemblyDefinition assembly = GetAssemblyDefinitionCached(assemblyPath, cache);
113-
if (assembly == null)
114-
throw new System.ArgumentException("Referenced Assembly " + Path.GetFileName(assemblyPath) + " could not be found!");
115-
116-
// Ignore it if we already added the assembly
117-
if (alreadyFoundAssemblies.IndexOf(assemblyPath) != -1)
118-
return;
119-
120-
alreadyFoundAssemblies.Add(assemblyPath);
121-
122-
var architectureSpecificPlugins = PluginImporter.GetImporters(target).Where(i =>
123-
{
124-
var cpu = i.GetPlatformData(target, "CPU");
125-
return !string.IsNullOrEmpty(cpu) && !string.Equals(cpu, "AnyCPU", StringComparison.InvariantCultureIgnoreCase);
126-
}).Select(i => Path.GetFileName(i.assetPath)).Distinct();
127-
128-
// Go through all referenced assemblies
129-
foreach (AssemblyNameReference referencedAssembly in assembly.MainModule.AssemblyReferences)
130-
{
131-
// Special cases for Metro
132-
if (referencedAssembly.Name == "BridgeInterface") continue;
133-
if (referencedAssembly.Name == "WinRTBridge") continue;
134-
if (referencedAssembly.Name == "UnityEngineProxy") continue;
135-
if (IgnoreAssembly(referencedAssembly.Name + ".dll", target, scriptingImplementation)) continue;
136-
137-
string foundPath = FindAssemblyName(referencedAssembly.FullName, referencedAssembly.Name, allAssemblyPaths, foldersToSearch, cache);
138-
139-
if (foundPath == "")
140-
{
141-
// Ignore architecture specific plugin references
142-
var found = false;
143-
foreach (var extension in new[] { ".dll", ".winmd" })
144-
{
145-
if (architectureSpecificPlugins.Any(p => string.Equals(p, referencedAssembly.Name + extension, StringComparison.InvariantCultureIgnoreCase)))
146-
{
147-
found = true;
148-
break;
149-
}
150-
}
151-
if (found)
152-
continue;
153-
throw new System.ArgumentException(string.Format("The Assembly {0} is referenced by {1} ('{2}'). But the dll is not allowed to be included or could not be found.",
154-
referencedAssembly.Name,
155-
assembly.MainModule.Assembly.Name.Name,
156-
assemblyPath));
157-
}
158-
159-
AddReferencedAssembliesRecurse(foundPath, alreadyFoundAssemblies, allAssemblyPaths, foldersToSearch, cache, target, scriptingImplementation);
160-
}
161-
}
162-
163-
static string FindAssemblyName(string fullName, string name, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary<string, AssemblyDefinition> cache)
164-
{
165-
// Search in provided assemblies
166-
for (int i = 0; i < allAssemblyPaths.Length; i++)
167-
{
168-
if (!File.Exists(allAssemblyPaths[i]))
169-
continue;
170-
171-
AssemblyDefinition definition = GetAssemblyDefinitionCached(allAssemblyPaths[i], cache);
172-
if (definition.MainModule.Assembly.Name.Name == name)
173-
return allAssemblyPaths[i];
174-
}
175-
176-
// Search in GAC
177-
foreach (string folder in foldersToSearch)
178-
{
179-
string pathInGacFolder = Path.Combine(folder, name + ".dll");
180-
if (File.Exists(pathInGacFolder))
181-
return pathInGacFolder;
182-
}
183-
return "";
184-
}
185-
186-
[RequiredByNativeCode]
187-
static public string[] FindAssembliesReferencedBy(string[] paths, string[] foldersToSearch, BuildTarget target, ScriptingImplementation scriptingImplementation)
188-
{
189-
List<string> unique = new List<string>();
190-
string[] allAssemblyPaths = paths;
191-
192-
var cache = new Dictionary<string, AssemblyDefinition>();
193-
for (int i = 0; i < paths.Length; i++)
194-
AddReferencedAssembliesRecurse(paths[i], unique, allAssemblyPaths, foldersToSearch, cache, target, scriptingImplementation);
195-
196-
for (int i = 0; i < paths.Length; i++)
197-
unique.Remove(paths[i]);
198-
199-
return unique.ToArray();
200-
}
201-
20229
static public bool IsUnityEngineModule(AssemblyDefinition assembly)
20330
{
20431
return assembly.CustomAttributes.Any(a => a.AttributeType.FullName == typeof(UnityEngineModuleAssembly).FullName);
@@ -209,33 +36,6 @@ static public bool IsUnityEngineModule(Assembly assembly)
20936
return assembly.GetCustomAttributes(typeof(UnityEngineModuleAssembly), false).Length > 0;
21037
}
21138

212-
private static bool IsTypeAUserExtendedScript(TypeReference type)
213-
{
214-
if (type == null || type.FullName == "System.Object")
215-
return false;
216-
217-
try
218-
{
219-
var typeDefinition = type.Resolve();
220-
var attributes = typeDefinition.CustomAttributes;
221-
for (var i = 0; i < attributes.Count; i++)
222-
{
223-
if (attributes[i].Constructor.DeclaringType.FullName == "UnityEngine.ExtensionOfNativeClassAttribute")
224-
return true;
225-
}
226-
227-
if (typeDefinition.BaseType != null)
228-
return IsTypeAUserExtendedScript(typeDefinition.BaseType);
229-
}
230-
catch (AssemblyResolutionException)
231-
{
232-
// just eat exception if we fail to load assembly here.
233-
// failure should be handled better in other places.
234-
}
235-
236-
return false;
237-
}
238-
23939
public static string[] GetDefaultAssemblySearchPaths()
24040
{
24141
// Add the path to all available precompiled assemblies
@@ -359,36 +159,6 @@ public static bool IsInternalAssembly(string file)
359159
return ModuleUtils.GetAdditionalReferencesForUserScripts().Any(p => p.Equals(file));
360160
}
361161

362-
const int kDefaultDepth = 10;
363-
internal static ICollection<string> FindAssemblies(string basePath)
364-
{
365-
return FindAssemblies(basePath, kDefaultDepth);
366-
}
367-
368-
internal static ICollection<string> FindAssemblies(string basePath, int maxDepth)
369-
{
370-
var assemblies = new List<string>();
371-
372-
if (0 == maxDepth)
373-
return assemblies;
374-
375-
try
376-
{
377-
DirectoryInfo directory = new DirectoryInfo(basePath);
378-
assemblies.AddRange(directory.GetFiles()
379-
.Where(file => IsManagedAssembly(file.FullName))
380-
.Select(file => file.FullName));
381-
foreach (DirectoryInfo subdirectory in directory.GetDirectories())
382-
assemblies.AddRange(FindAssemblies(subdirectory.FullName, maxDepth - 1));
383-
}
384-
catch (Exception)
385-
{
386-
// Return what we have now
387-
}
388-
389-
return assemblies;
390-
}
391-
392162
/// <summary>
393163
/// Performs a depth-first-search topological sort on the input assemblies,
394164
/// based on the outgoing assembly references from each assembly. The

Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static IEnumerator<T> FindInFolders<T>(SearchFilter searchFilter, Func<H
8888
{
8989
// Set filter after we found the folder
9090
if (propertyWithFilter != null)
91-
propertyWithFilter.CopySearchFilterFrom(property);
91+
property.CopySearchFilterFrom(propertyWithFilter);
9292
else
9393
{
9494
property.SetSearchFilter(searchFilter);

Editor/Mono/AssetPipeline/SpeedTreeImporter.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ private static void FixExtraTexture_sRGB(IEnumerable<UnityEngine.Object> subAsse
284284
texImporter.sRGBTexture = false; // extra texture does not contain color data, hence shouldn't be sRGB.
285285
texImporter.SaveAndReimport();
286286
}
287+
288+
287289
}
288290
}
289291
}

Editor/Mono/AssetPipeline/TextureImporter.bindings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ public void SetTextureSettings(TextureImporterSettings src)
468468
internal extern bool removeMatte { get; set; }
469469

470470
public extern bool ignorePngGamma { get; set; }
471-
internal static readonly int MaxTextureSizeAllowedForReadable = 8192; //keep in sync with TextureImporter.h
472471

473472
// This is for remapping Sprite that are renamed.
474473
extern internal bool GetNameFromInternalIDMap(long id, ref string name);

Editor/Mono/BuildPipeline.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ private static bool DoesBuildTargetSupportPlayerConnectionPlayerToEditor(BuildTa
738738
targetPlatform == BuildTarget.StandaloneWindows ||
739739
targetPlatform == BuildTarget.StandaloneWindows64 ||
740740
targetPlatform == BuildTarget.StandaloneLinux64 ||
741+
targetPlatform == BuildTarget.iOS ||
741742
// Android: support connection from player to Editor in both cases
742743
// connecting to 127.0.0.1 (when both Editor and Android are on localhost using USB cable)
743744
// connecting to <ip of machine where the Editor is running>, the Android and PC has to be on the same subnet

0 commit comments

Comments
 (0)