Skip to content

Commit 6113073

Browse files
author
Unity Technologies
committed
Unity 6000.0.17f1 C# reference source code
1 parent 0782d04 commit 6113073

File tree

44 files changed

+516
-325
lines changed

Some content is hidden

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

44 files changed

+516
-325
lines changed

Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary.Data/Data.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public class Il2CppConfig
9292
public string[] AdditionalCppFiles = new string[0];
9393
public string[] AdditionalArgs = new string[0];
9494
public string CompilerFlags;
95+
public string[] AdditionalLibraries;
96+
public string[] AdditionalDefines;
97+
public string[] AdditionalIncludeDirectories;
98+
public string[] AdditionalLinkDirectories;
9599
public string LinkerFlags;
96100
public string LinkerFlagsFile;
97101
public string ExtraTypes;

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121

2222
namespace UnityEditor.SpeedTree.Importer
2323
{
24-
[ScriptedImporter(1, "st9", AllowCaching = true)]
24+
// [2024-08-07] version: 2
25+
// Fixed mesh's UV2 & UV3 data usage strategy to 'always allocate' from 'conditionally allocate'
26+
// to fix unwanted application of leaf-facing effect to geometries without leaf-facing data.
27+
28+
[ScriptedImporter(version: 2, ext: "st9", AllowCaching = true)]
2529
public class SpeedTree9Importer : ScriptedImporter
2630
{
2731
const int SPEEDTREE_9_WIND_VERSION = 1;
@@ -212,10 +216,10 @@ public override void OnImportAsset(AssetImportContext ctx)
212216

213217
AddDependencyOnExtractedMaterials();
214218

215-
TriggerAllCabback();
219+
TriggerAllCallbacks();
216220
}
217221

218-
private void TriggerAllCabback()
222+
private void TriggerAllCallbacks()
219223
{
220224
var allMethods = AttributeHelper.GetMethodsWithAttribute<MaterialSettingsCallbackAttribute>().methodsWithAttributes;
221225
foreach (var method in allMethods)
@@ -259,7 +263,7 @@ internal void RegenerateMaterials()
259263

260264
RegenerateAndPopulateExternalMaterials(this.assetPath);
261265

262-
TriggerAllCabback();
266+
TriggerAllCallbacks();
263267
}
264268
finally
265269
{
@@ -346,17 +350,13 @@ private Mesh CreateMeshAndGeometry(Lod lod, int lodIndex)
346350

347351
mesh.SetUVs(0, sTMeshGeometry.uvs[0]);
348352
mesh.SetUVs(1, sTMeshGeometry.uvs[1]);
349-
350353
if (!isBillboard)
351354
{
352-
if (m_HasBranch2Data || m_HasFacingData) // If Branch2 is available:
353-
{
354-
mesh.SetUVs(2, sTMeshGeometry.uvs[2]); // Branch2Pos, Branch2Dir, Branch2Weight, <Unused>
355-
}
356-
if (m_HasBranch2Data && m_HasFacingData) // If camera-facing geom is available:
357-
{
358-
mesh.SetUVs(3, sTMeshGeometry.uvs[3]); // 2/3 Anchor XYZ, FacingFlag
359-
}
355+
// SpeedTree shader expects certain UV2 & UV3 values for leaf facing & wind.
356+
// if we don't claim them here now, tree rendering may break when Unity
357+
// uses UV2 & UV3 and the shader finds unexpected values.
358+
mesh.SetUVs(2, sTMeshGeometry.uvs[2]); // Branch2Pos, Branch2Dir, Branch2Weight, <Unused>
359+
mesh.SetUVs(3, sTMeshGeometry.uvs[3]); // 2/3 Anchor XYZ, FacingFlag
360360
}
361361

362362
return mesh;
@@ -453,23 +453,23 @@ private void CalculateMeshGeometry(STMeshGeometry sTMeshGeometry, Lod lod, bool
453453

454454
if (!isBillboard)
455455
{
456-
if (m_HasBranch2Data)
457-
{
458-
sTMeshGeometry.uvs[currentUV++][i].Set(
459-
vertex.BranchWind2.X,
460-
vertex.BranchWind2.Y,
461-
vertex.BranchWind2.Z,
462-
0.0f);
463-
}
464-
465-
if (m_HasFacingData)
466-
{
467-
sTMeshGeometry.uvs[currentUV++][i].Set(
468-
vertex.Anchor.X * m_MeshSettings.scaleFactor,
469-
vertex.Anchor.Y * m_MeshSettings.scaleFactor,
470-
vertex.Anchor.Z * m_MeshSettings.scaleFactor,
471-
vertex.CameraFacing ? 1.0f : 0.0f);
472-
}
456+
float anchorX = m_HasFacingData ? vertex.Anchor.X * m_MeshSettings.scaleFactor : 0.0f;
457+
float anchorY = m_HasFacingData ? vertex.Anchor.Y * m_MeshSettings.scaleFactor : 0.0f;
458+
float anchorZ = m_HasFacingData ? vertex.Anchor.Z * m_MeshSettings.scaleFactor : 0.0f;
459+
float leafFacingFlag = vertex.CameraFacing ? 1.0f : 0.0f;
460+
461+
sTMeshGeometry.uvs[currentUV++][i].Set(
462+
m_HasBranch2Data ? vertex.BranchWind2.X : anchorX,
463+
m_HasBranch2Data ? vertex.BranchWind2.Y : anchorY,
464+
m_HasBranch2Data ? vertex.BranchWind2.Z : anchorZ,
465+
m_HasBranch2Data ? 0.0f /*UNUSED*/ : leafFacingFlag);
466+
467+
bool useUV3 = m_HasBranch2Data && m_HasFacingData;
468+
sTMeshGeometry.uvs[currentUV++][i].Set(
469+
useUV3 ? anchorX : 0.0f,
470+
useUV3 ? anchorY : 0.0f,
471+
useUV3 ? anchorZ : 0.0f,
472+
useUV3 ? leafFacingFlag : 0.0f);
473473
}
474474
}
475475
}
@@ -502,15 +502,7 @@ private int CalculateNumUVs(bool isBillboard)
502502
int numUVs = 2;
503503
if (!isBillboard)
504504
{
505-
if (m_HasBranch2Data)
506-
{
507-
numUVs += 1;
508-
}
509-
510-
if (m_HasFacingData)
511-
{
512-
numUVs += 1;
513-
}
505+
numUVs += 2; // reserve UV2 & UV3 for 3D-geometry to detect leaf facing (VS effect) correctly
514506
}
515507
return numUVs;
516508
}

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public abstract class Sysroot
3434
public abstract string GetSysrootPath();
3535
public abstract string GetToolchainPath();
3636
public abstract string GetIl2CppCompilerFlags();
37+
// The sysroot package does not currently contain an implemenation for this method, adding a default implementation to avoid breaking stuff
38+
public virtual string[] GetIl2CppAdditionalLibraries() => Array.Empty<string>();
39+
// The sysroot package does not currently contain an implemenation for this method, adding a default implementation to avoid breaking stuff
40+
public virtual string[] GetIl2CppAdditionalDefines() => Array.Empty<string>();
41+
// The sysroot package does not currently contain an implemenation for this method, adding a default implementation to avoid breaking stuff
42+
public virtual string[] GetIl2CppAdditionalIncludeDirectories() => Array.Empty<string>();
43+
// The sysroot package does not currently contain an implemenation for this method, adding a default implementation to avoid breaking stuff
44+
public virtual string[] GetIl2CppAdditionalLinkDirectories() => Array.Empty<string>();
3745
public abstract string GetIl2CppLinkerFlags();
3846
// The sysroot package does not currently contain an implemenation for this method, adding a default implementation to avoid breaking stuff
3947
public virtual string GetIl2CppLinkerFlagsFile() => null;

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ void OnEnable()
206206

207207
void OnDisable()
208208
{
209+
var playerSettingsDirty = EditorUtility.IsDirty(m_PlayerSettings);
210+
if (playerSettingsDirty)
211+
{
212+
BuildProfileModuleUtil.SerializePlayerSettings(this);
213+
EditorUtility.SetDirty(this);
214+
}
215+
209216
// OnDisable is called when entering play mode, during domain reloads, or when the object is destroyed.
210217
// Avoid removing player settings for the first two cases to prevent slow syncs (e.g., color space) caused by global manager updates.
211218
if (!EditorApplication.isUpdating)

Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,5 +538,78 @@ public static (BuildTarget, StandaloneBuildSubtarget) GetBuildTargetAndSubtarget
538538
{
539539
return BuildTargetDiscovery.GetBuildTargetAndSubtargetFromGUID(new GUID(platformId));
540540
}
541+
542+
public static string[] GetSettingsRequiringRestart(PlayerSettings previousProfileSettings, PlayerSettings newProfileSettings, BuildTarget oldBuildTarget, BuildTarget newBuildTarget)
543+
{
544+
return PlayerSettings.GetSettingsRequiringRestart(previousProfileSettings, newProfileSettings, oldBuildTarget, newBuildTarget);
545+
}
546+
547+
public static PlayerSettings GetGlobalPlayerSettings()
548+
{
549+
return BuildProfile.GetGlobalPlayerSettings();
550+
}
551+
552+
/// <summary>
553+
/// Show the restart editor dialog with the names of the settings that required the restart to take effect
554+
/// </summary>
555+
public static bool ShowRestartEditorDialog(string[] settingsRequiringRestart)
556+
{
557+
var editorPromptText = new System.Text.StringBuilder();
558+
editorPromptText.AppendLine(L10n.Tr("The Unity editor must be restarted for the following settings to take effect:"));
559+
for (int i = 0; i < settingsRequiringRestart.Length; i++)
560+
{
561+
editorPromptText.AppendLine(settingsRequiringRestart[i]);
562+
}
563+
564+
return EditorUtility.DisplayDialog(L10n.Tr("Unity editor restart required"), editorPromptText.ToString(), L10n.Tr("Apply"), L10n.Tr("Cancel"));
565+
}
566+
567+
public static void RestartEditor()
568+
{
569+
EditorApplication.RestartEditorAndRecompileScripts();
570+
}
571+
572+
public static bool HandlePlayerSettingsRequiringRestart(BuildProfile currentBuildProfile, BuildProfile nextBuildProfile, BuildTarget currentBuildTarget, BuildTarget nextBuildTarget)
573+
{
574+
575+
PlayerSettings projectSettingsPlayerSettings = GetGlobalPlayerSettings();
576+
PlayerSettings currentPlayerSettings = projectSettingsPlayerSettings;
577+
PlayerSettings nextPlayerSettings = projectSettingsPlayerSettings;
578+
579+
if (currentBuildProfile != null)
580+
{
581+
if (currentBuildProfile.playerSettings != null)
582+
{
583+
currentPlayerSettings = currentBuildProfile.playerSettings;
584+
}
585+
}
586+
587+
if (nextBuildProfile != null)
588+
{
589+
if (nextBuildProfile.playerSettings != null)
590+
{
591+
nextPlayerSettings = nextBuildProfile.playerSettings;
592+
}
593+
}
594+
595+
string[] settingsRequiringRestart = GetSettingsRequiringRestart(currentPlayerSettings,
596+
nextPlayerSettings, currentBuildTarget, nextBuildTarget);
597+
// if we've found settings that need restarting..
598+
if (settingsRequiringRestart.Length > 0 )
599+
{
600+
// ..we show the restart prompt, if the user restarts, we add a restart call to the editor
601+
if (ShowRestartEditorDialog(settingsRequiringRestart))
602+
{
603+
EditorApplication.delayCall += () => RestartEditor();
604+
}
605+
else
606+
{
607+
// if the user cancels the restart, then we failed to handle the settings
608+
return false;
609+
}
610+
}
611+
// all other outcomes are a success: found no settings to restart or the user agreed to restart
612+
return true;
613+
}
541614
}
542615
}

Editor/Mono/BuildProfile/BuildProfilePlayerSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,10 @@ static void TryLoadProjectSettingsAssetPlayerSettings()
215215
if (s_GlobalPlayerSettings == null)
216216
s_GlobalPlayerSettings = AssetDatabase.LoadAssetAtPath<PlayerSettings>(k_ProjectSettingsAssetPath);
217217
}
218+
219+
internal static PlayerSettings GetGlobalPlayerSettings()
220+
{
221+
return s_GlobalPlayerSettings;
222+
}
218223
}
219224
}

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class SettingsContent
265265
public static readonly string undoChangedDefaultShaderChunkCountString = L10n.Tr("Changed Shader Chunk Count Default Setting");
266266

267267
public static readonly string globalPlayerSettingsInfo =
268-
L10n.Tr("Editing these global player settings will not affect the current state of the project, because the active build profile is using it's own customized player setitngs. Edit the build profile to change them.");
268+
L10n.Tr("Editing these global player settings will not affect the current state of the project, because the active build profile is using its own customized player settings. Edit the build profile to change them.");
269269
public static readonly string globalPlayerSettingsInfoButton = L10n.Tr("Edit Build Profile");
270270
}
271271

@@ -2217,7 +2217,8 @@ private void OtherSectionRenderingGUI(BuildPlatform platform, ISettingEditorExte
22172217
api == GraphicsDeviceType.Direct3D11 ||
22182218
api == GraphicsDeviceType.Metal ||
22192219
api == GraphicsDeviceType.Vulkan ||
2220-
api == GraphicsDeviceType.OpenGLES3)
2220+
api == GraphicsDeviceType.OpenGLES3 ||
2221+
api == GraphicsDeviceType.Direct3D12)
22212222
{
22222223
platformSupportsBatching = true;
22232224
break;
@@ -3108,6 +3109,10 @@ private void OtherSectionConfigurationGUI(BuildPlatform platform, ISettingEditor
31083109
EditorGUILayout.PropertyField(m_GCIncremental, SettingsContent.gcIncremental);
31093110
if (m_GCIncremental.boolValue != oldValue)
31103111
{
3112+
if (!IsActivePlayerSettingsEditor())
3113+
{
3114+
return;
3115+
}
31113116
// Give the user a chance to change mind and revert changes.
31123117
if (ShouldRestartEditorToApplySetting())
31133118
{
@@ -3194,6 +3199,10 @@ private void OtherSectionConfigurationGUI(BuildPlatform platform, ISettingEditor
31943199

31953200
if (m_ActiveInputHandler.intValue != currValue)
31963201
{
3202+
if (!IsActivePlayerSettingsEditor())
3203+
{
3204+
return;
3205+
}
31973206
// Give the user a chance to change mind and revert changes.
31983207
if (ShouldRestartEditorToApplySetting())
31993208
{

Editor/Mono/Modules/BeeBuildPostprocessor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ IEnumerable<string> SplitArgs(string args)
273273

274274
protected virtual string Il2CppCompilerFlagsFor(BuildPostProcessArgs args) => null;
275275

276+
protected virtual string[] Il2CppAdditionalLibrariesFor(BuildPostProcessArgs args) => Array.Empty<string>();
277+
protected virtual string[] Il2CppAdditionalDefinesFor(BuildPostProcessArgs args) => Array.Empty<string>();
278+
protected virtual string[] Il2CppAdditionalIncludeDirectoriesFor(BuildPostProcessArgs args) => Array.Empty<string>();
279+
protected virtual string[] Il2CppAdditionalLinkDirectoriesFor(BuildPostProcessArgs args) => Array.Empty<string>();
280+
276281
protected virtual string Il2CppLinkerFlagsFor(BuildPostProcessArgs args) => null;
277282

278283
protected virtual string Il2CppLinkerFlagsFileFor(BuildPostProcessArgs args) => null;
@@ -296,6 +301,10 @@ Il2CppConfig Il2CppConfigFor(BuildPostProcessArgs args)
296301
var sysrootPath = Il2CppSysrootPathFor(args);
297302
var toolchainPath = Il2CppToolchainPathFor(args);
298303
var compilerFlags = Il2CppCompilerFlagsFor(args);
304+
var additionalLibraries = Il2CppAdditionalLibrariesFor(args);
305+
var additionalDefines = Il2CppAdditionalDefinesFor(args);
306+
var additionalIncludeDirectories = Il2CppAdditionalIncludeDirectoriesFor(args);
307+
var additionalLinkDirectories = Il2CppAdditionalLinkDirectoriesFor(args);
299308
var linkerFlags = Il2CppLinkerFlagsFor(args);
300309
var linkerFlagsFile = Il2CppLinkerFlagsFileFor(args);
301310
var relativeDataPath = Il2CppDataRelativePath(args);
@@ -345,6 +354,10 @@ Il2CppConfig Il2CppConfigFor(BuildPostProcessArgs args)
345354
AdditionalArgs = additionalArgs.ToArray(),
346355
AllowDebugging = allowDebugging,
347356
CompilerFlags = compilerFlags,
357+
AdditionalLibraries = additionalLibraries,
358+
AdditionalDefines = additionalDefines,
359+
AdditionalIncludeDirectories = additionalIncludeDirectories,
360+
AdditionalLinkDirectories = additionalLinkDirectories,
348361
LinkerFlags = linkerFlags,
349362
LinkerFlagsFile = linkerFlagsFile,
350363
SysRootPath = sysrootPath,

Editor/Mono/Modules/DefaultBuildProfileExtension.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,10 @@ public virtual void OnDisable()
9191
public VisualElement CreateSettingsGUI(
9292
SerializedObject serializedObject, SerializedProperty rootProperty, BuildProfileWorkflowState workflowState)
9393
{
94-
var platformWarningsGUI = CreatePlatformBuildWarningsGUI(serializedObject, rootProperty);
9594
var commonSettingsGUI = CreateCommonSettingsGUI(serializedObject, rootProperty, workflowState);
9695
var platformSettingsGUI = CreatePlatformSettingsGUI(serializedObject, rootProperty, workflowState);
9796

9897
var settingsGUI = new VisualElement();
99-
if (platformWarningsGUI != null)
100-
settingsGUI.Add(platformWarningsGUI);
10198
settingsGUI.Add(platformSettingsGUI);
10299
if (BuildPlayerWindow.WillDrawMultiplayerBuildOptions())
103100
settingsGUI.Add(CreateMultiplayerSettingsGUI(serializedObject.targetObject as BuildProfile));

Editor/Mono/Modules/PlatformSupportModule.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,23 @@ VisualElement CreateSettingsGUI(
392392
SerializedProperty rootProperty,
393393
BuildProfileWorkflowState state);
394394

395+
/// <summary>
396+
/// When editing a build profile asset, this method is invoked to render the
397+
/// warning help boxes for build related issues.
398+
/// </summary>
399+
/// <param name="serializedObject">
400+
/// Target Build Profile serialized object .
401+
/// </param>
402+
/// <param name="rootProperty">
403+
/// Property instance for <see cref="BuildProfile.platformBuildProfile"/>.
404+
/// </param>
405+
/// <returns>
406+
/// Root visual element for the platform specific warnings.
407+
/// </returns>
408+
VisualElement CreatePlatformBuildWarningsGUI(
409+
SerializedObject serializedObject,
410+
SerializedProperty rootProperty);
411+
395412
/// <summary>
396413
/// Copy settings to the platform settings base we are passing. This is used, for example, when creating
397414
/// a new classic profile and we need to copy settings - that live in the managed side only - to it

Editor/Mono/Overlays/OverlayCanvas.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,10 +837,7 @@ void SetActiveOverlayPopup(OverlayPopup popup)
837837
if (evt.relatedTarget == null && m_PopupOverlay.containsCursor)
838838
EditorApplication.delayCall += m_PopupOverlay.Focus;
839839
else
840-
{
841840
ClosePopupOverlay();
842-
popup.overlay.OnWillBeDestroyed();
843-
}
844841
});
845842

846843
rootVisualElement.Add(m_PopupOverlay);
@@ -852,6 +849,7 @@ internal bool ClosePopupOverlay()
852849
if (m_PopupOverlay == null)
853850
return false;
854851

852+
m_PopupOverlay.overlay.OnWillBeDestroyed();
855853
m_PopupOverlay.RemoveFromHierarchy();
856854
m_PopupOverlay = null;
857855
return true;

Editor/Mono/PlayerSettings.bindings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,5 +1774,8 @@ internal static extern bool iosCopyPluginsCodeInsteadOfSymlink
17741774
internal static extern void UpdatePlayerSettingsObjectFromYAML(PlayerSettings playerSettings, string yamlSettings);
17751775

17761776
internal static extern bool platformRequiresReadableAssets { get; set; }
1777+
1778+
[StaticAccessor("PlayerSettings", StaticAccessorType.DoubleColon)]
1779+
internal static extern string[] GetSettingsRequiringRestart(PlayerSettings prevSettings, PlayerSettings newSettings, BuildTarget prevBuildTarget, BuildTarget newBuildTarget);
17771780
}
17781781
}

0 commit comments

Comments
 (0)