Skip to content

Commit 1f8a545

Browse files
author
Unity Technologies
committed
Unity 6000.0.9f1 C# reference source code
1 parent c4a2a4d commit 1f8a545

File tree

34 files changed

+602
-114
lines changed

34 files changed

+602
-114
lines changed

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,13 @@ static ulong CombineHash(ulong h1, ulong h2)
287287
static ulong ComputeDefaultShaderHash()
288288
{
289289
ulong newDefaultShaderHash = 0UL;
290-
if (GraphicsSettings.currentRenderPipeline == null || GraphicsSettings.currentRenderPipeline.defaultSpeedTree9Shader == null)
290+
if (GraphicsSettings.GetDefaultShader(DefaultShaderType.SpeedTree9) == null)
291291
{
292292
newDefaultShaderHash = 0;
293293
}
294294
else
295295
{
296-
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(GraphicsSettings.currentRenderPipeline.defaultSpeedTree9Shader, out var guid,
296+
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(GraphicsSettings.GetDefaultShader(DefaultShaderType.SpeedTree9), out var guid,
297297
out long fileId))
298298
{
299299
newDefaultShaderHash = CombineHash((ulong)guid.GetHashCode(), (ulong)fileId);
@@ -1382,12 +1382,7 @@ private bool TreeHasFacingData()
13821382

13831383
internal static bool TryGetShaderForCurrentRenderPipeline(out Shader shader)
13841384
{
1385-
shader = null;
1386-
if (GraphicsSettings.currentRenderPipeline != null)
1387-
{
1388-
shader = GraphicsSettings.currentRenderPipeline.defaultSpeedTree9Shader;
1389-
}
1390-
1385+
shader = GraphicsSettings.GetDefaultShader(DefaultShaderType.SpeedTree9);
13911386
if (shader == null)
13921387
{
13931388
shader = Shader.Find(ImporterSettings.kLegacyShaderName);
@@ -1522,7 +1517,7 @@ private static bool TryGetHashSpeedTreeAttributeMaterialSettings(out List<string
15221517
private static void ChangeTextureImporterSettingsForSt9Files(string assetPath)
15231518
{
15241519
SpeedTree9Reader tree = new SpeedTree9Reader();
1525-
1520+
15261521
FileStatus status = tree.Initialize(assetPath);
15271522
if (status != FileStatus.Valid)
15281523
{

Editor/Mono/BuildTargetDiscovery.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ internal static bool DoesBuildTargetSupportSinglePassStereoRendering(BuildTarget
479479
{ s_platform_05, "Windows" },
480480
{ s_platform_09, "iOS" },
481481
{ s_platform_13, "Android™" },
482-
{ s_platform_20, "WebGL" },
482+
{ s_platform_20, "Web" },
483483
{ s_platform_21, "Universal Windows Platform" },
484484
{ s_platform_24, "Linux" },
485485
{ s_platform_31, "PlayStation®4" },

Editor/Mono/GI/InputExtraction.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ internal static class BindingsMarshaller
7070

7171
public static extern bool ExtractFromScene(string outputFolderPath, LightBaker.BakeInput input, LightBaker.LightmapRequests lightmapRequests, LightBaker.LightProbeRequests lightProbeRequests, SourceMap map);
7272

73+
[NativeMethod(IsThreadSafe = true)]
7374
public static extern int[] ComputeOcclusionLightIndicesFromBakeInput(LightBaker.BakeInput bakeInput, UnityEngine.Vector3[] probePositions, uint maxLightsPerProbe);
7475

76+
[NativeMethod(IsThreadSafe = true)]
77+
public static extern int[] GetShadowmaskChannelsFromLightIndices(LightBaker.BakeInput bakeInput, int[] lightIndices);
78+
7579
private static string LookupGameObjectName(SourceMap map, int instanceIndex)
7680
{
7781
if (map == null)

Editor/Mono/GI/InputExtraction.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,10 @@ public static int[] ComputeOcclusionLightIndicesFromBakeInput(BakeInput bakeInpu
6161
{
6262
return UnityEditor.LightBaking.InputExtraction.ComputeOcclusionLightIndicesFromBakeInput(bakeInput.bakeInput, probePositions, maxLightsPerProbe);
6363
}
64+
65+
public static int[] GetShadowmaskChannelsFromLightIndices(BakeInput bakeInput, int[] lightIndices)
66+
{
67+
return UnityEditor.LightBaking.InputExtraction.GetShadowmaskChannelsFromLightIndices(bakeInput.bakeInput, lightIndices);
68+
}
6469
}
6570
}

Editor/Mono/SceneHierarchy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ internal void CreateSceneHeaderContextClick(GenericMenu menu, Scene scene)
15911591

15921592
// Ping Scene Asset
15931593
menu.AddSeparator("");
1594-
var selectAssetContent = EditorGUIUtility.TrTextContent("Find in project");
1594+
var selectAssetContent = EditorGUIUtility.TrTextContent("Find In Project");
15951595
if (!string.IsNullOrEmpty(scene.path))
15961596
menu.AddItem(selectAssetContent, false, SelectSceneAsset, scene);
15971597
else

Editor/Mono/Shaders/ShaderKeywordFilterData.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,26 +233,35 @@ internal static SettingsNode GatherFilterData(string nodeName, object containerO
233233
{
234234
var enumerable = value as IEnumerable;
235235

236-
bool hasDifferentChildren = (node != null) && (node.m_Children.Count > 0);
237-
foreach (var e in enumerable)
236+
// UUM-72309 - A crash occured due to a third party package throwing when accessing its enumerator.
237+
// This try/catch should prevent such issues and log an error.
238+
try
238239
{
239-
var childVisited = new HashSet<object>(visited);
240-
SettingsNode newBranch = GatherFilterData(f.Name, e, childVisited, containerConstraints);
241-
if (newBranch != null)
240+
bool hasDifferentChildren = (node != null) && (node.m_Children.Count > 0);
241+
foreach (var e in enumerable)
242242
{
243-
if (node == null)
244-
node = new SettingsNode(nodeName);
245-
246-
if (hasDifferentChildren)
243+
var childVisited = new HashSet<object>(visited);
244+
SettingsNode newBranch = GatherFilterData(f.Name, e, childVisited, containerConstraints);
245+
if (newBranch != null)
247246
{
248-
Debug.LogError("ShaderKeywordFilter attributes cannot be placed on a settings tree with multiple different branches on the same level.");
249-
}
250-
else
251-
{
252-
node.m_Children.Add(newBranch);
247+
if (node == null)
248+
node = new SettingsNode(nodeName);
249+
250+
if (hasDifferentChildren)
251+
{
252+
Debug.LogError("ShaderKeywordFilter attributes cannot be placed on a settings tree with multiple different branches on the same level.");
253+
}
254+
else
255+
{
256+
node.m_Children.Add(newBranch);
257+
}
253258
}
254259
}
255260
}
261+
catch(Exception ex)
262+
{
263+
Debug.LogError($"An error occured while processing ShaderKeywordFilter attributes; Reading node: {nodeName} and field: {f.Name}\n {ex.Message}");
264+
}
256265
}
257266
else if (!type.IsValueType || (type.IsValueType && !type.IsPrimitive && !type.IsEnum)) // class or struct
258267
{

Editor/Mono/SpeedTreeMaterialFixer.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ public static void DoFixerUI(GameObject gameObject)
4646
if (s_Styles == null)
4747
s_Styles = new Styles();
4848

49-
var srpAsset = GraphicsSettings.currentRenderPipeline;
50-
51-
var defaultSpeedTree8Shader = srpAsset != null ? srpAsset.defaultSpeedTree8Shader : null;
49+
var defaultSpeedTree8Shader = GraphicsSettings.GetDefaultShader(DefaultShaderType.SpeedTree8);
5250
if (defaultSpeedTree8Shader == null)
5351
defaultSpeedTree8Shader = Shader.Find("Nature/SpeedTree8");
5452

55-
var defaultSpeedTree7Shader = srpAsset != null ? srpAsset.defaultSpeedTree7Shader : null;
53+
var defaultSpeedTree7Shader = GraphicsSettings.GetDefaultShader(DefaultShaderType.SpeedTree7);
5654
if (defaultSpeedTree7Shader == null)
5755
defaultSpeedTree7Shader = Shader.Find("Nature/SpeedTree");
5856

Modules/Audio/Public/ScriptBindings/Audio.bindings.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,11 @@ extern public int timeSamples
728728
}
729729

730730
// The default [[AudioClip]] to play
731-
[NativeProperty("AudioClip")]
732-
extern public AudioClip clip { get; set; }
731+
public AudioClip clip
732+
{
733+
get => resource as AudioClip;
734+
set => resource = value as AudioClip;
735+
}
733736

734737
extern public AudioResource resource { get; set; }
735738

Modules/BuildProfileEditor/Handlers/BuildProfileDataSource.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ internal class BuildProfileDataSource : IDisposable
2020

2121
const string k_AssetFolderPath = "Assets/Settings/Build Profiles";
2222

23-
static string GetNewProfileName(string displayName) => $"{k_AssetFolderPath}/{displayName}.asset";
23+
static string GetDefaultNewProfilePath(string platformDisplayName) =>
24+
$"{k_AssetFolderPath}/New {platformDisplayName} Profile.asset";
25+
26+
static string GetDefaultNewProfilePath(GUID platformGuid)
27+
{
28+
var platformDisplayName = BuildProfileModuleUtil.GetClassicPlatformDisplayName(platformGuid.ToString());
29+
return GetDefaultNewProfilePath(platformDisplayName);
30+
}
2431

2532
internal BuildProfileDataSource(BuildProfileWindow window)
2633
{
@@ -86,14 +93,13 @@ internal List<BuildProfile> DuplicateProfiles(List<BuildProfile> profilesToDupli
8693
}
8794

8895
/// <summary>
89-
/// Create a custom build profile asset, making sure to create the folders
90-
/// if needed
96+
/// Create a new custom build profile asset with the default name.
97+
/// Ensure that custom build profile folders is created if it doesn't already exist.
9198
/// </summary>
92-
internal static void CreateAsset(string platformId, string displayName)
99+
internal static void CreateNewAsset(string platformId, string platformDisplayName)
93100
{
94-
CheckCreateCustomBuildProfileFolders();
95-
96-
BuildProfile.CreateInstance(platformId, GetNewProfileName(displayName));
101+
EnsureCustomBuildProfileFolderExists();
102+
BuildProfile.CreateInstance(platformId, GetDefaultNewProfilePath(platformDisplayName));
97103
}
98104

99105
/// <summary>
@@ -105,7 +111,7 @@ internal static BuildProfile DuplicateAsset(BuildProfile buildProfile, bool isCl
105111
if (buildProfile == null)
106112
return null;
107113

108-
string path = isClassic ? GetDuplicatedBuildProfilePathForClassic(buildProfile) : AssetDatabase.GetAssetPath(buildProfile);
114+
string path = isClassic ? GetDefaultNewProfilePath(new GUID(buildProfile.platformId)) : AssetDatabase.GetAssetPath(buildProfile);
109115
if (string.IsNullOrEmpty(path))
110116
return null;
111117

@@ -116,7 +122,7 @@ internal static BuildProfile DuplicateAsset(BuildProfile buildProfile, bool isCl
116122
if (isClassic)
117123
duplicatedProfile.scenes = EditorBuildSettings.GetEditorBuildSettingsSceneIgnoreProfile();
118124

119-
CheckCreateCustomBuildProfileFolders();
125+
EnsureCustomBuildProfileFolderExists();
120126

121127
string uniqueFilePath = AssetDatabase.GenerateUniqueAssetPath(path);
122128
AssetDatabase.CreateAsset(duplicatedProfile, uniqueFilePath);
@@ -301,13 +307,7 @@ static string ReplaceFileNameInPath(string originalPath, string newName)
301307
return Path.Combine(directory, $"{newName}{extension}");
302308
}
303309

304-
static string GetDuplicatedBuildProfilePathForClassic(BuildProfile buildProfile)
305-
{
306-
string name = BuildProfileModuleUtil.GetClassicPlatformDisplayName(buildProfile.platformId);
307-
return Path.Combine(k_AssetFolderPath, $"{name}.asset");
308-
}
309-
310-
static void CheckCreateCustomBuildProfileFolders()
310+
static void EnsureCustomBuildProfileFolderExists()
311311
{
312312
if (!AssetDatabase.IsValidFolder("Assets/Settings"))
313313
AssetDatabase.CreateFolder("Assets", "Settings");

Modules/BuildProfileEditor/PlatformDiscoveryWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ ListView CreateCardListView()
148148
/// </summary>
149149
static void OnAddBuildProfileClicked(BuildProfileCard card)
150150
{
151-
BuildProfileDataSource.CreateAsset(card.platformId, card.displayName);
151+
BuildProfileDataSource.CreateNewAsset(card.platformId, card.displayName);
152152
EditorAnalytics.SendAnalytic(new BuildProfileCreatedEvent(new BuildProfileCreatedEvent.Payload
153153
{
154154
creationType = BuildProfileCreatedEvent.CreationType.PlatformBrowser,

0 commit comments

Comments
 (0)