Skip to content

Commit d0e1a5b

Browse files
author
Unity Technologies
committed
Unity 2023.3.0a13 C# reference source code
1 parent cc405f6 commit d0e1a5b

File tree

148 files changed

+1646
-882
lines changed

Some content is hidden

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

148 files changed

+1646
-882
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 UnityEngine;
6+
using UnityEngine.UIElements;
7+
8+
namespace UnityEditor.Audio.UIElements
9+
{
10+
internal class OnAudioFilterReadLevelMeter : IMGUIContainer
11+
{
12+
AudioFilterGUI m_IMGUI_AudioFilterGUI = new AudioFilterGUI();
13+
14+
public OnAudioFilterReadLevelMeter(MonoBehaviour behaviour)
15+
{
16+
onGUIHandler = () => { m_IMGUI_AudioFilterGUI.DrawAudioFilterGUI(behaviour); };
17+
}
18+
}
19+
}

Editor/Mono/BuildPipeline/RuntimeClassMetadata.cs

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using UnityEditor.Compilation;
1010
using UnityEditor.Scripting.ScriptCompilation;
1111
using UnityEngine.Scripting;
12+
using System.Diagnostics;
1213

1314
namespace UnityEditor
1415
{
@@ -53,8 +54,16 @@ public void AddNativeClassID(int ID)
5354
[RequiredByNativeCode]
5455
public void SetUsedTypesInUserAssembly(string[] typeNames, string assemblyName)
5556
{
56-
if (!m_UsedTypesPerUserAssembly.TryGetValue(assemblyName, out HashSet<string> types))
57-
m_UsedTypesPerUserAssembly[assemblyName] = types = new HashSet<string>();
57+
string assemblyFileName = assemblyName;
58+
if (!assemblyFileName.EndsWith(".dll"))
59+
{
60+
assemblyFileName = assemblyName + ".dll";
61+
}
62+
63+
if (!m_UsedTypesPerUserAssembly.TryGetValue(assemblyFileName, out HashSet<string> types))
64+
{
65+
m_UsedTypesPerUserAssembly[assemblyFileName] = types = new HashSet<string>();
66+
}
5867

5968
foreach (var typeName in typeNames)
6069
types.Add(typeName);
@@ -77,40 +86,43 @@ public void SetSerializedTypesInUserAssembly(string[] typeNames, string assembly
7786
"Unity.Analytics.dll",
7887
};
7988

80-
static string[] UserAssemblies
89+
private static string[] GetTargetUserAssemblyNames()
8190
{
82-
get
83-
{
84-
EditorCompilation.TargetAssemblyInfo[] allTargetAssemblies = EditorCompilationInterface.GetTargetAssemblyInfos();
91+
EditorCompilation.TargetAssemblyInfo[] allTargetAssemblies = EditorCompilationInterface.GetTargetAssemblyInfos();
8592

86-
string[] targetAssemblyNames = new string[allTargetAssemblies.Length + s_TreatedAsUserAssemblies.Length];
93+
string[] targetAssemblyNames = new string[allTargetAssemblies.Length + s_TreatedAsUserAssemblies.Length];
8794

88-
for (int i = 0; i < allTargetAssemblies.Length; ++i)
89-
{
90-
targetAssemblyNames[i] = allTargetAssemblies[i].Name;
91-
}
92-
for (int i = 0; i < s_TreatedAsUserAssemblies.Length; ++i)
93-
{
94-
targetAssemblyNames[allTargetAssemblies.Length + i] = s_TreatedAsUserAssemblies[i];
95-
}
96-
return targetAssemblyNames;
95+
for (int i = 0; i < allTargetAssemblies.Length; ++i)
96+
{
97+
targetAssemblyNames[i] = allTargetAssemblies[i].Name;
98+
}
99+
for (int i = 0; i < s_TreatedAsUserAssemblies.Length; ++i)
100+
{
101+
targetAssemblyNames[allTargetAssemblies.Length + i] = s_TreatedAsUserAssemblies[i];
102+
}
103+
for (int i=0; i<targetAssemblyNames.Length; ++i)
104+
{
105+
if (!targetAssemblyNames[i].EndsWith(".dll"))
106+
targetAssemblyNames[i] += ".dll";
97107
}
108+
return targetAssemblyNames;
98109
}
99110

100-
public bool IsDLLUsed(string dll)
111+
private bool IsAssemblyDLLUsed(string assemblyName, string[] userAssemblyNames)
101112
{
113+
Debug.Assert(assemblyName.EndsWith(".dll"));
102114
if (m_UsedTypesPerUserAssembly == null)
103115
return true;
104116

105-
if (Array.IndexOf(UserAssemblies, dll) != -1)
117+
if (Array.IndexOf(userAssemblyNames, assemblyName) != -1)
106118
{
107119
// Don't treat code in packages as used automatically (case 1003047).
108-
var asmdefPath = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName(dll);
120+
var asmdefPath = CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName(assemblyName);
109121
if (asmdefPath == null || !EditorCompilationInterface.Instance.IsPathInPackageDirectory(asmdefPath))
110122
return true;
111123
}
112-
113-
return m_UsedTypesPerUserAssembly.ContainsKey(dll);
124+
bool isUsed = m_UsedTypesPerUserAssembly.ContainsKey(assemblyName);
125+
return isUsed;
114126
}
115127

116128
protected void AddUsedClass(string assemblyName, string className)
@@ -121,8 +133,15 @@ protected void AddUsedClass(string assemblyName, string className)
121133
if (string.IsNullOrEmpty(className))
122134
throw new ArgumentException(nameof(className));
123135

124-
if (!m_UsedTypesPerUserAssembly.TryGetValue(assemblyName, out HashSet<string> types))
125-
m_UsedTypesPerUserAssembly[assemblyName] = types = new HashSet<string>();
136+
string assemblyFileName = assemblyName;
137+
if (!assemblyFileName.EndsWith(".dll"))
138+
{
139+
assemblyFileName = assemblyName + ".dll";
140+
}
141+
if (!m_UsedTypesPerUserAssembly.TryGetValue(assemblyFileName, out HashSet<string> types))
142+
{
143+
m_UsedTypesPerUserAssembly[assemblyFileName] = types = new HashSet<string>();
144+
}
126145

127146
types.Add(className);
128147
}
@@ -172,11 +191,23 @@ public Dictionary<string, string[]> GetAllManagedTypesInScenes()
172191
engineModuleTypes.Add(managedName);
173192
}
174193

175-
items.Add("UnityEngine.dll", engineModuleTypes.ToArray());
176-
194+
bool engineModuleTypesAdded = false;
177195
foreach (var userAssembly in m_UsedTypesPerUserAssembly)
178-
items.Add(userAssembly.Key, userAssembly.Value.ToArray());
196+
{
197+
if (userAssembly.Key == "UnityEngine.dll" && !engineModuleTypesAdded)
198+
{
199+
engineModuleTypes.UnionWith(userAssembly.Value);
200+
items.Add(userAssembly.Key, engineModuleTypes.ToArray());
201+
engineModuleTypesAdded = true;
202+
continue;
203+
}
179204

205+
items.Add(userAssembly.Key, userAssembly.Value.ToArray());
206+
}
207+
if (!engineModuleTypesAdded)
208+
{
209+
items.Add("UnityEngine.dll", engineModuleTypes.ToArray());
210+
}
180211
return items;
181212
}
182213

@@ -285,6 +316,10 @@ internal void AddUserAssembly(string assembly)
285316
m_UserAssemblies.Add(assembly);
286317
}
287318

288-
internal string[] GetUserAssemblies() => m_UserAssemblies.Where(s => IsDLLUsed(s)).ToArray();
319+
internal string[] GetUsedUserAssemblies()
320+
{
321+
var userAssemblyNames = GetTargetUserAssemblyNames();
322+
return m_UserAssemblies.Where(s => IsAssemblyDLLUsed(s, userAssemblyNames)).ToArray();
323+
}
289324
}
290325
}

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static public string GetPlaybackEngineDownloadURL(string moduleName)
631631
return string.Format("http://{0}.unity3d.com/{1}/{2}/{3}/UnitySetup-{4}-Support-for-Editor-{5}{6}", prefix, suffix, revision, folder, moduleName, shortVersion, extension);
632632
}
633633

634-
static string GetUnityHubModuleDownloadURL(string moduleName)
634+
internal static string GetUnityHubModuleDownloadURL(string moduleName)
635635
{
636636
string fullVersion = InternalEditorUtility.GetFullUnityVersion();
637637
string revision = "";
@@ -651,7 +651,7 @@ static string GetUnityHubModuleDownloadURL(string moduleName)
651651
return string.Format("unityhub://{0}/{1}/module={2}", shortVersion, revision, moduleName.ToLower());
652652
}
653653

654-
bool IsModuleNotInstalled(NamedBuildTarget namedBuildTarget, BuildTarget buildTarget)
654+
internal static bool IsModuleNotInstalled(NamedBuildTarget namedBuildTarget, BuildTarget buildTarget)
655655
{
656656
bool licensed = BuildPipeline.LicenseCheck(buildTarget);
657657
bool installed = BuildPlatforms.instance.BuildPlatformFromNamedBuildTarget(namedBuildTarget).installed;
@@ -706,26 +706,11 @@ void ShowBuildTargetSettings()
706706

707707
if (IsModuleNotInstalled(namedBuildTarget, buildTarget))
708708
{
709-
GUILayout.Label(EditorGUIUtility.TextContent(string.Format(styles.noModuleLoaded, BuildPlatforms.instance.GetModuleDisplayName(namedBuildTarget, buildTarget))));
710-
string url = "";
711-
712-
if (!isEditorinstalledWithHub || (moduleName == "PS4" || moduleName == "PS5" || moduleName == "XboxOne"))
713-
{
714-
if (GUILayout.Button(styles.openDownloadPage, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
715-
{
716-
url = GetPlaybackEngineDownloadURL(moduleName);
717-
Help.BrowseURL(url);
718-
}
719-
}
720-
else
721-
{
722-
if (GUILayout.Button(styles.installModuleWithHub, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
723-
{
724-
url = GetUnityHubModuleDownloadURL(moduleName);
725-
Help.BrowseURL(url);
726-
}
727-
}
728-
GUILayout.Label(styles.EditorWillNeedToBeReloaded, EditorStyles.wordWrappedMiniLabel);
709+
ShowNoModuleLabel(namedBuildTarget, buildTarget, moduleName,
710+
styles.noModuleLoaded,
711+
styles.openDownloadPage,
712+
styles.installModuleWithHub,
713+
styles.EditorWillNeedToBeReloaded);
729714
GUIBuildButtons(false, false, false, platform, postprocessor);
730715
return;
731716
}
@@ -954,6 +939,38 @@ void ShowBuildTargetSettings()
954939
canInstallInBuildFolder, platform, postprocessor);
955940
}
956941

942+
internal static void ShowNoModuleLabel(
943+
NamedBuildTarget namedBuildTarget,
944+
BuildTarget buildTarget,
945+
string moduleName,
946+
string noModuleLoaded,
947+
GUIContent openDownloadPage,
948+
GUIContent installModuleWithHub,
949+
string editorWillNeedToBeReloaded)
950+
{
951+
GUILayout.Label(EditorGUIUtility.TextContent(string.Format(noModuleLoaded, BuildPlatforms.instance.GetModuleDisplayName(namedBuildTarget, buildTarget))));
952+
string url = "";
953+
954+
if (!isEditorinstalledWithHub || (moduleName == "PS4" || moduleName == "PS5" || moduleName == "XboxOne"))
955+
{
956+
if (GUILayout.Button(openDownloadPage, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
957+
{
958+
url = GetPlaybackEngineDownloadURL(moduleName);
959+
Help.BrowseURL(url);
960+
}
961+
}
962+
else
963+
{
964+
if (GUILayout.Button(installModuleWithHub, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
965+
{
966+
url = GetUnityHubModuleDownloadURL(moduleName);
967+
Help.BrowseURL(url);
968+
}
969+
}
970+
971+
GUILayout.Label(editorWillNeedToBeReloaded, EditorStyles.wordWrappedMiniLabel);
972+
}
973+
957974
private static void GUIBuildButtons(bool enableBuildButton,
958975
bool enableBuildAndRunButton,
959976
bool canInstallInBuildFolder,

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Runtime.InteropServices;
77
using UnityEngine;
8+
using UnityEngine.Bindings;
89
using UnityEngine.Scripting;
910

1011
namespace UnityEditor.Build.Profile
@@ -14,6 +15,7 @@ namespace UnityEditor.Build.Profile
1415
/// </summary>
1516
[RequiredByNativeCode(GenerateProxy = true)]
1617
[StructLayout(LayoutKind.Sequential)]
18+
[VisibleToOtherModules]
1719
internal sealed partial class BuildProfile : ScriptableObject
1820
{
1921
/// <summary>
@@ -36,6 +38,16 @@ public StandaloneBuildSubtarget subtarget
3638
internal set => m_Subtarget = value;
3739
}
3840

41+
/// <summary>
42+
/// Module name used to fetch build profiles.
43+
/// </summary>
44+
[SerializeField] string m_ModuleName;
45+
public string moduleName
46+
{
47+
get => m_ModuleName;
48+
internal set => m_ModuleName = value;
49+
}
50+
3951
/// <summary>
4052
/// Platform module specific build settings; e.g. AndroidBuildSettings.
4153
/// </summary>

0 commit comments

Comments
 (0)