Skip to content

Commit e740821

Browse files
author
Unity Technologies
committed
Unity 2022.1.0a13 C# reference source code
1 parent bf5ada6 commit e740821

File tree

302 files changed

+13740
-3560
lines changed

Some content is hidden

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

302 files changed

+13740
-3560
lines changed

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
[assembly: InternalsVisibleTo("Unity.UIElements.Tests")]
125125
[assembly: InternalsVisibleTo("Unity.UIElements.PlayModeTests")]
126126
[assembly: InternalsVisibleTo("Unity.UIElements.EditorTests")]
127+
[assembly: InternalsVisibleTo("Unity.TextCore.Editor.Tests")]
127128
[assembly: InternalsVisibleTo("UnityEditor.UIElementsGameObjectsModule")]
128129
[assembly: InternalsVisibleTo("UnityEditor.TextCoreTextEngineModule")]
129130
[assembly: InternalsVisibleTo("Unity.TextMeshPro.Editor")]

Editor/Mono/AssetPipeline/TextureGenerator.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public TextureGenerationSettings(TextureImporterType type)
144144
m_Settings.mipmapFadeDistanceEnd = 3;
145145
m_Settings.heightmapScale = 0.25f;
146146
m_Settings.normalMapFilter = TextureImporterNormalFilter.Standard;
147+
m_Settings.flipGreenChannel = false;
148+
m_Settings.swizzleRaw = 0x03020100; // R,G,B,A
147149
m_Settings.cubemapConvolution = 0;
148150
m_Settings.generateCubemap = TextureImporterGenerateCubemap.AutoCubemap;
149151
m_Settings.seamlessCubemap = false;

Editor/Mono/AssetPipeline/TextureImporter.bindings.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,32 @@ public bool lightmap
308308
set { if (value) textureType = TextureImporterType.Lightmap; else textureType = TextureImporterType.Default; }
309309
}
310310

311-
// Convert heightmap to normal map?
312311
public extern bool convertToNormalmap { get; set; }
313-
// Is this texture a normal map?
314312
public extern TextureImporterNormalFilter normalmapFilter { get; set; }
315-
// Amount of bumpyness in the heightmap.
313+
public extern bool flipGreenChannel { get; set; }
314+
315+
extern uint swizzle { get; set; }
316+
public TextureImporterSwizzle swizzleR
317+
{
318+
get => (TextureImporterSwizzle)(swizzle & 0xFF);
319+
set => swizzle = (swizzle & 0xFFFFFF00) | (uint)value;
320+
}
321+
public TextureImporterSwizzle swizzleG
322+
{
323+
get => (TextureImporterSwizzle)((swizzle >> 8) & 0xFF);
324+
set => swizzle = (swizzle & 0xFFFF00FF) | ((uint)value<<8);
325+
}
326+
public TextureImporterSwizzle swizzleB
327+
{
328+
get => (TextureImporterSwizzle)((swizzle >> 16) & 0xFF);
329+
set => swizzle = (swizzle & 0xFF00FFFF) | ((uint)value<<16);
330+
}
331+
public TextureImporterSwizzle swizzleA
332+
{
333+
get => (TextureImporterSwizzle)((swizzle >> 24) & 0xFF);
334+
set => swizzle = (swizzle & 0x00FFFFFF) | ((uint)value<<24);
335+
}
336+
316337
[NativeProperty("NormalmapHeightScale")]
317338
public extern float heightmapScale { get; set; }
318339

@@ -439,7 +460,6 @@ public void SetTextureSettings(TextureImporterSettings src)
439460
internal extern bool textureStillNeedsToBeCompressed { [NativeName("DoesTextureStillNeedToBeCompressed")] get; }
440461

441462
// This is pure backward compatibility codepath. It can be removed when we decide that the time has come
442-
internal extern bool ShouldShowRemoveMatteOption();
443463
internal extern bool removeMatte { get; set; }
444464

445465
public extern bool ignorePngGamma { get; set; }

Editor/Mono/AssetPipeline/TextureImporterEnums.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,18 @@ public enum AndroidETC2FallbackOverride
368368
// 32-bit uncompressed, downscaled 2x
369369
Quality32BitDownscaled = 3
370370
}
371+
372+
public enum TextureImporterSwizzle
373+
{
374+
R = 0,
375+
G = 1,
376+
B = 2,
377+
A = 3,
378+
OneMinusR = 4,
379+
OneMinusG = 5,
380+
OneMinusB = 6,
381+
OneMinusA = 7,
382+
Zero = 8,
383+
One = 9
384+
}
371385
}

Editor/Mono/AssetPipeline/TextureImporterTypes.bindings.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public sealed partial class TextureImporterSettings
5757
[SerializeField]
5858
int m_NormalMapFilter;
5959
[SerializeField]
60+
int m_FlipGreenChannel;
61+
[SerializeField]
62+
uint m_Swizzle;
63+
[SerializeField]
6064
int m_IsReadable;
6165

6266
[SerializeField]
@@ -264,6 +268,37 @@ public TextureImporterNormalFilter normalMapFilter
264268
get {return (TextureImporterNormalFilter)m_NormalMapFilter; }
265269
set { m_NormalMapFilter = (int)value; }
266270
}
271+
public bool flipGreenChannel
272+
{
273+
get => m_FlipGreenChannel != 0;
274+
set => m_FlipGreenChannel = value ? 1 : 0;
275+
}
276+
277+
public TextureImporterSwizzle swizzleR
278+
{
279+
get => (TextureImporterSwizzle)(m_Swizzle & 0xFF);
280+
set => m_Swizzle = (m_Swizzle & 0xFFFFFF00) | (uint)value;
281+
}
282+
public TextureImporterSwizzle swizzleG
283+
{
284+
get => (TextureImporterSwizzle)((m_Swizzle >> 8) & 0xFF);
285+
set => m_Swizzle = (m_Swizzle & 0xFFFF00FF) | ((uint)value<<8);
286+
}
287+
public TextureImporterSwizzle swizzleB
288+
{
289+
get => (TextureImporterSwizzle)((m_Swizzle >> 16) & 0xFF);
290+
set => m_Swizzle = (m_Swizzle & 0xFF00FFFF) | ((uint)value<<16);
291+
}
292+
public TextureImporterSwizzle swizzleA
293+
{
294+
get => (TextureImporterSwizzle)((m_Swizzle >> 24) & 0xFF);
295+
set => m_Swizzle = (m_Swizzle & 0x00FFFFFF) | ((uint)value<<24);
296+
}
297+
internal uint swizzleRaw
298+
{
299+
get => m_Swizzle;
300+
set => m_Swizzle = value;
301+
}
267302
public TextureImporterAlphaSource alphaSource
268303
{
269304
get {return (TextureImporterAlphaSource)m_AlphaSource; }

Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,7 @@ internal static ShaderCompilerData[] OnPreprocessShaders(Shader shader, ShaderSn
492492
{
493493
foreach (IPreprocessShaders abtc in processors.shaderProcessors)
494494
{
495-
try
496-
{
497-
abtc.OnProcessShader(shader, snippet, dataList);
498-
}
499-
catch (Exception e)
500-
{
501-
Debug.LogException(e);
502-
}
495+
abtc.OnProcessShader(shader, snippet, dataList);
503496
}
504497
}
505498
return dataList.ToArray();

Editor/Mono/BuildPipeline/DataBuildDirtyTracker.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ class BuildDataInputFile
2020
public string path;
2121
public string contentHash;
2222

23-
public BuildDataInputFile(NPath npath)
23+
public BuildDataInputFile(NPath npath, bool developmentBuild)
2424
{
2525
path = npath.ToString();
2626
if (npath.HasExtension("cs"))
2727
{
2828
var monoScript = AssetDatabase.LoadAssetAtPath<MonoScript>(path);
2929
if (monoScript != null)
30-
contentHash = monoScript.GetPropertiesHashString();
30+
contentHash = monoScript.GetPropertiesHashString(developmentBuild);
3131
}
3232
else
33-
{
3433
contentHash = AssetDatabase.GetAssetDependencyHash(npath.ToString()).ToString();
35-
}
3634
}
3735
}
3836

@@ -68,19 +66,17 @@ bool CheckAssetDirty(BuildDataInputFile file)
6866
return true;
6967
}
7068

71-
string hash = "";
69+
string contentHash = "";
7270
if (path.Extension == "cs")
7371
{
7472
var monoScript = AssetDatabase.LoadAssetAtPath<MonoScript>(path.ToString());
7573
if (monoScript != null)
76-
hash = monoScript.GetPropertiesHashString();
74+
contentHash = monoScript.GetPropertiesHashString(buildOptions.HasFlag(BuildOptions.Development));
7775
}
7876
else
79-
{
80-
hash = AssetDatabase.GetAssetDependencyHash(path.ToString()).ToString();
81-
}
77+
contentHash = AssetDatabase.GetAssetDependencyHash(file.path).ToString();
8278

83-
if (hash != file.contentHash)
79+
if (contentHash != file.contentHash)
8480
{
8581
Console.WriteLine($"Rebuilding Data files because {path} is dirty (hash)");
8682
return true;
@@ -103,7 +99,7 @@ bool DoCheckDirty()
10399
return true;
104100
}
105101

106-
if (buildOptions != buildData.buildOptions)
102+
if ((buildOptions & BuildData.BuildOptionsMask) != buildData.buildOptions)
107103
{
108104
Console.WriteLine("Rebuilding Data files because the build options have changed");
109105
return true;
@@ -147,22 +143,23 @@ bool DoCheckDirty()
147143
[RequiredByNativeCode]
148144
static public void WriteBuildData(string buildDataPath, BuildReport report, string[] scenes, string[] prefabs)
149145
{
146+
var developmentBuild = report.summary.options.HasFlag(BuildOptions.Development);
150147
var inputScenes = new List<BuildDataInputFile>();
151148
foreach (var scene in scenes)
152-
inputScenes.Add(new BuildDataInputFile(scene));
149+
inputScenes.Add(new BuildDataInputFile(scene, developmentBuild));
153150

154151
var inputFiles = new List<BuildDataInputFile>();
155152
foreach (var scene in scenes)
156-
inputFiles.Add(new BuildDataInputFile(scene));
153+
inputFiles.Add(new BuildDataInputFile(scene, developmentBuild));
157154
foreach (var prefab in prefabs)
158-
inputFiles.Add(new BuildDataInputFile(prefab));
155+
inputFiles.Add(new BuildDataInputFile(prefab, developmentBuild));
159156
foreach (var assetInfo in report.packedAssets.SelectMany(a => a.contents))
160157
{
161158
if (assetInfo.sourceAssetPath.ToNPath().FileExists() && !assetInfo.sourceAssetPath.StartsWith("."))
162-
inputFiles.Add(new BuildDataInputFile(assetInfo.sourceAssetPath));
159+
inputFiles.Add(new BuildDataInputFile(assetInfo.sourceAssetPath, developmentBuild));
163160
}
164161
foreach (var projectSetting in new NPath("ProjectSettings").Files("*.asset"))
165-
inputFiles.Add(new BuildDataInputFile(projectSetting));
162+
inputFiles.Add(new BuildDataInputFile(projectSetting, developmentBuild));
166163

167164
var buildData = new BuildData()
168165
{
@@ -189,7 +186,7 @@ static public bool CheckDirty(string buildDataPath, BuildOptions buildOptions, s
189186
{
190187
buildData = JsonUtility.FromJson<BuildData>(buildReportPath.ReadAllText()),
191188
scenes = scenes,
192-
buildOptions = buildOptions & BuildData.BuildOptionsMask
189+
buildOptions = buildOptions
193190
};
194191
return tracker.DoCheckDirty();
195192
}

Editor/Mono/BuildPipeline/DesktopStandaloneBuildWindowExtension.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,16 @@ protected virtual string GetCannotBuildPlayerInCurrentSetupError()
207207
{
208208
var namedBuildTarget = EditorUserBuildSettingsUtils.CalculateSelectedNamedBuildTarget();
209209

210-
if (namedBuildTarget == NamedBuildTarget.Server && !m_HasServerPlayers)
211-
return $"Dedicated Server support for {GetHostPlatformName()} is not installed";
210+
if (namedBuildTarget == NamedBuildTarget.Server)
211+
{
212+
if(!m_HasServerPlayers)
213+
return $"Dedicated Server support for {GetHostPlatformName()} is not installed";
214+
215+
if (PlayerSettings.GetScriptingBackend(namedBuildTarget) == ScriptingImplementation.IL2CPP && !m_IsRunningOnHostPlatform)
216+
return string.Format("{0} IL2CPP player can only be built on {0}.", GetHostPlatformName());
217+
218+
return null;
219+
}
212220

213221
if (PlayerSettings.GetScriptingBackend(namedBuildTarget) != ScriptingImplementation.IL2CPP)
214222
{
@@ -220,8 +228,7 @@ protected virtual string GetCannotBuildPlayerInCurrentSetupError()
220228
if (!m_IsRunningOnHostPlatform)
221229
return string.Format("{0} IL2CPP player can only be built on {0}.", GetHostPlatformName());
222230

223-
// Il2cpp is always shipped in the Server support installer for the host platform.
224-
if (!m_HasIl2CppPlayers && namedBuildTarget != NamedBuildTarget.Server)
231+
if (!m_HasIl2CppPlayers)
225232
return "Currently selected scripting backend (IL2CPP) is not installed."; // Note: error should match UWP player error message for consistency.
226233
}
227234

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using UnityEditor.Build;
1414
using UnityEditor.Build.Player;
1515
using UnityEditor.Build.Reporting;
16+
using UnityEditor.CrashReporting;
1617
using UnityEditor.Il2Cpp;
1718
using UnityEditor.Scripting;
1819
using UnityEditor.Scripting.Compilers;
@@ -760,6 +761,9 @@ private void ConvertPlayerDlltoCpp(Il2CppBuildPipelineData data)
760761
arguments.Add(buildingArgument);
761762
}
762763

764+
if (CrashReportingSettings.enabled)
765+
arguments.Add($"--emit-source-mapping");
766+
763767
var additionalArgs = IL2CPPUtils.GetAdditionalArguments();
764768
if (!string.IsNullOrEmpty(additionalArgs))
765769
arguments.Add(additionalArgs);

Editor/Mono/BuildPipeline/NamedBuildTarget.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace UnityEditor.Build
2929
"GameCoreXboxOne",
3030
"PS5",
3131
"EmbeddedLinux",
32+
"QNX",
3233
};
3334

3435
public static readonly NamedBuildTarget Unknown = new NamedBuildTarget("");
@@ -45,6 +46,7 @@ namespace UnityEditor.Build
4546
public static readonly NamedBuildTarget Stadia = new NamedBuildTarget("Stadia");
4647
public static readonly NamedBuildTarget CloudRendering = new NamedBuildTarget("CloudRendering");
4748
public static readonly NamedBuildTarget EmbeddedLinux = new NamedBuildTarget("EmbeddedLinux");
49+
public static readonly NamedBuildTarget QNX = new NamedBuildTarget("QNX");
4850

4951
public string TargetName { get; }
5052

@@ -99,6 +101,8 @@ public static NamedBuildTarget FromBuildTargetGroup(BuildTargetGroup buildTarget
99101
return NamedBuildTarget.CloudRendering;
100102
case BuildTargetGroup.EmbeddedLinux:
101103
return NamedBuildTarget.EmbeddedLinux;
104+
case BuildTargetGroup.QNX:
105+
return NamedBuildTarget.QNX;
102106

103107
// Build targets that are not explicitly listed
104108
case BuildTargetGroup.Lumin:

Editor/Mono/BuildTarget.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public enum BuildTarget
133133

134134
EmbeddedLinux = 45,
135135

136+
QNX = 46,
137+
136138
// obsolete identifiers. We're using different values so that ToString() works.
137139
[System.Obsolete("Use iOS instead (UnityUpgradable) -> iOS", true)]
138140
iPhone = -1,

Editor/Mono/BuildTargetConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ internal static class BuildTargetConverter
5050
return RuntimePlatform.Stadia;
5151
case BuildTarget.EmbeddedLinux:
5252
return RuntimePlatform.EmbeddedLinuxArm64;
53+
case BuildTarget.QNX:
54+
return RuntimePlatform.QNXArm64;
5355
default:
5456
return null;
5557
}

Editor/Mono/BuildTargetGroup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,7 @@ public enum BuildTargetGroup
109109
PS5 = 33,
110110

111111
EmbeddedLinux = 34,
112+
113+
QNX = 35,
112114
}
113115
}

Editor/Mono/ConsoleWindow.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ enum ConsoleFlags
248248
static ConsoleWindow ms_ConsoleWindow = null;
249249
private string m_SearchText;
250250

251+
static readonly int k_HasSpaceForExtraButtonsCutoff = 420;
252+
251253
public static void ShowConsoleWindow(bool immediate)
252254
{
253255
if (!ms_ConsoleWindow)
@@ -476,7 +478,7 @@ void UpdateListView()
476478

477479
bool HasSpaceForExtraButtons()
478480
{
479-
return position.width > 420;
481+
return position.width > k_HasSpaceForExtraButtonsCutoff;
480482
}
481483

482484
internal void OnGUI()
@@ -543,7 +545,7 @@ internal void OnGUI()
543545
if (HasSpaceForExtraButtons())
544546
{
545547
SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPause, Constants.MiniButton));
546-
PlayerConnectionGUILayout.ConnectionTargetSelectionDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown);
548+
PlayerConnectionGUILayout.ConnectionTargetSelectionDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown, (int)(position.width - k_HasSpaceForExtraButtonsCutoff) + 80 );
547549
}
548550

549551
GUILayout.FlexibleSpace();

Editor/Mono/EditorApplication.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ internal static string GetDefaultMainWindowTitle(ApplicationTitleDescriptor desc
329329

330330
[RequiredByNativeCode]
331331
internal static string BuildMainWindowTitle()
332+
{
333+
var desc = GetApplicationTitleDescriptor();
334+
updateMainWindowTitle?.Invoke(desc);
335+
336+
return desc.title;
337+
}
338+
339+
internal static ApplicationTitleDescriptor GetApplicationTitleDescriptor()
332340
{
333341
var activeSceneName = L10n.Tr("Untitled");
334342
if (!string.IsNullOrEmpty(SceneManager.GetActiveScene().path))
@@ -347,9 +355,7 @@ internal static string BuildMainWindowTitle()
347355

348356
desc.title = GetDefaultMainWindowTitle(desc);
349357

350-
updateMainWindowTitle?.Invoke(desc);
351-
352-
return desc.title;
358+
return desc;
353359
}
354360

355361
[RequiredByNativeCode]

0 commit comments

Comments
 (0)