Skip to content

Commit 70832e6

Browse files
author
Unity Technologies
committed
Unity 2023.1.0a18 C# reference source code
1 parent 332310b commit 70832e6

File tree

123 files changed

+5892
-4244
lines changed

Some content is hidden

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

123 files changed

+5892
-4244
lines changed

Editor/Mono/AssemblyHelper.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Debug = UnityEngine.Debug;
2020
using Unity.Profiling;
2121
using UnityEditor.AssetImporters;
22+
using UnityEditor.Scripting.ScriptCompilation;
2223
using UnityEngine.Scripting.APIUpdating;
2324

2425
namespace UnityEditor
@@ -258,24 +259,28 @@ public static string[] GetDefaultAssemblySearchPaths()
258259
}
259260

260261
[RequiredByNativeCode]
261-
public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out string[] classNamesArray, out string[] classNameSpacesArray, out string[] movedFromNamespacesArray)
262+
public static bool ExtractAllClassesThatAreUserExtendedScripts(string path, out string[] classNamesArray, out string[] classNameSpacesArray, out string[] movedFromNamespacesArray)
262263
{
263264
var typesDerivedFromMonoBehaviour = TypeCache.GetTypesDerivedFrom<MonoBehaviour>();
264265
var typesDerivedFromScriptableObject = TypeCache.GetTypesDerivedFrom<ScriptableObject>();
265266
var typesDerivedFromScriptedImporter = TypeCache.GetTypesDerivedFrom<ScriptedImporter>();
266267

267-
var fullPath = Path.GetFullPath(path);
268-
IEnumerable<Type> userTypes = typesDerivedFromMonoBehaviour.Where(x => Path.GetFullPath(x.Assembly.Location) == fullPath);
268+
var fileName = Path.GetFileName(path);
269+
IEnumerable<Type> userTypes = typesDerivedFromMonoBehaviour.Where(x => Path.GetFileName(x.Assembly.Location) == fileName);
269270
userTypes = userTypes
270-
.Concat(typesDerivedFromScriptableObject.Where(x => Path.GetFullPath(x.Assembly.Location) == fullPath))
271-
.Concat(typesDerivedFromScriptedImporter.Where(x => Path.GetFullPath(x.Assembly.Location) == fullPath)).ToList();
271+
.Concat(typesDerivedFromScriptableObject.Where(x => Path.GetFileName(x.Assembly.Location) == fileName))
272+
.Concat(typesDerivedFromScriptedImporter.Where(x => Path.GetFileName(x.Assembly.Location) == fileName)).ToList();
272273

273274
List<string> classNames = new List<string>(userTypes.Count());
274275
List<string> nameSpaces = new List<string>(userTypes.Count());
275276
List<string> originalNamespaces = new List<string>(userTypes.Count());
276277

278+
string pathToAssembly = null;
277279
foreach (var userType in userTypes)
278280
{
281+
if (string.IsNullOrEmpty(pathToAssembly))
282+
pathToAssembly = Path.GetFullPath(userType.Assembly.Location);
283+
279284
classNames.Add(userType.Name);
280285
nameSpaces.Add(userType.Namespace);
281286

@@ -286,6 +291,8 @@ public static void ExtractAllClassesThatAreUserExtendedScripts(string path, out
286291
classNamesArray = classNames.ToArray();
287292
classNameSpacesArray = nameSpaces.ToArray();
288293
movedFromNamespacesArray = originalNamespaces.ToArray();
294+
295+
return !Utility.IsPathsEqual(pathToAssembly, path);
289296
}
290297

291298
/// Extract information about all types in the specified assembly, searchDirs might be used to resolve dependencies.

Editor/Mono/BuildPipeline.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public class BuildPipeline
255255
[FreeFunction(IsThreadSafe = true)]
256256
public static extern BuildTargetGroup GetBuildTargetGroup(BuildTarget platform);
257257

258+
// Uses the implementation in "BuildPipeline.bindings.h"
258259
internal static extern BuildTargetGroup GetBuildTargetGroupByName(string platform);
259260

260261
internal static extern BuildTarget GetBuildTargetByName(string platform);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using UnityEngine.Scripting;
7+
8+
namespace UnityEditor;
9+
10+
internal partial class CustomEditorAttributes
11+
{
12+
[RequiredByNativeCode]
13+
internal static Type FindCustomEditorType(Object o, bool multiEdit)
14+
{
15+
return FindCustomEditorTypeByType(o.GetType(), multiEdit);
16+
}
17+
18+
[RequiredByNativeCode]
19+
internal static Type FindCustomEditorTypeByType(Type type, bool multiEdit)
20+
{
21+
return instance.GetCustomEditorType(type, multiEdit);
22+
}
23+
}

Editor/Mono/CustomEditorAttributes.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
using UnityEditorInternal;
1313
using UnityEngine;
1414
using UnityEngine.Rendering;
15-
using Object = UnityEngine.Object;
1615

1716
namespace UnityEditor
1817
{
19-
internal class CustomEditorAttributes
18+
internal partial class CustomEditorAttributes
2019
{
2120
static CustomEditorAttributes instance => k_Instance.Value;
2221

@@ -44,17 +43,7 @@ internal class CustomEditorAttributes
4443
Rebuild();
4544
}
4645

47-
internal static Type FindCustomEditorType(Object o, bool multiEdit)
48-
{
49-
return FindCustomEditorTypeByType(o.GetType(), multiEdit);
50-
}
51-
52-
internal static Type FindCustomEditorTypeByType(Type type, bool multiEdit)
53-
{
54-
return instance.FindCustomEditorType(type, multiEdit);
55-
}
56-
57-
Type FindCustomEditorType(Type type, bool multiEdit)
46+
Type GetCustomEditorType(Type type, bool multiEdit)
5847
{
5948
if (type == null)
6049
return null;
@@ -307,7 +296,7 @@ internal void Add(Type type, CustomEditor inspectAttr, MonoEditorType monoEditor
307296
if (type.GetCustomAttribute<CanEditMultipleObjects>(false) != null)
308297
storage.customEditorsMultiEdition.AddSorted(monoEditorType, m_SortUnityTypesFirstComparer);
309298

310-
if(!isItExistInCache)
299+
if (!isItExistInCache)
311300
m_CustomEditorCache.Add(inspectAttr.m_InspectedType, storage);
312301
}
313302

Editor/Mono/EditorApplication.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public enum PlayModeStateChange
3232
internal enum ScriptChangesDuringPlayOptions
3333
{
3434
RecompileAndContinuePlaying = 0,
35-
// RecompileAfterFinishedPlaying = 1, Deprecated feature
35+
RecompileAfterFinishedPlaying = 1,
3636
StopPlayingAndRecompile = 2
3737
}
3838

0 commit comments

Comments
 (0)