Skip to content

Commit c4a2a4d

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

File tree

182 files changed

+3251
-1792
lines changed

Some content is hidden

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

182 files changed

+3251
-1792
lines changed

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ private void TriggerAllCabback()
228228
private void CacheTreeImporterValues(string assetPath)
229229
{
230230
// Variables used a lot are cached, since accessing any Reader array has a non-negligeable cost.
231+
m_LODCount = (uint)m_Tree.Lod.Length;
231232
m_HasFacingData = TreeHasFacingData();
232233
m_HasBranch2Data = m_Tree.Wind.DoBranch2;
233234
m_LastLodIsBillboard = m_Tree.BillboardInfo.LastLodIsBillboard;
234-
m_LODCount = (uint)m_Tree.Lod.Length;
235235
m_CollisionObjectsCount = (uint)m_Tree.CollisionObjects.Length;
236236

237237
WindConfigSDK windCfg = m_Tree.Wind;
@@ -349,13 +349,13 @@ private Mesh CreateMeshAndGeometry(Lod lod, int lodIndex)
349349

350350
if (!isBillboard)
351351
{
352-
if (m_HasBranch2Data || m_HasFacingData)
352+
if (m_HasBranch2Data || m_HasFacingData) // If Branch2 is available:
353353
{
354-
mesh.SetUVs(2, sTMeshGeometry.uvs[2]);
354+
mesh.SetUVs(2, sTMeshGeometry.uvs[2]); // Branch2Pos, Branch2Dir, Branch2Weight, <Unused>
355355
}
356-
if (m_HasBranch2Data && m_HasFacingData)
356+
if (m_HasBranch2Data && m_HasFacingData) // If camera-facing geom is available:
357357
{
358-
mesh.SetUVs(3, sTMeshGeometry.uvs[3]);
358+
mesh.SetUVs(3, sTMeshGeometry.uvs[3]); // 2/3 Anchor XYZ, FacingFlag
359359
}
360360
}
361361

@@ -405,17 +405,12 @@ private void CalculateMeshGeometry(STMeshGeometry sTMeshGeometry, Lod lod, bool
405405
STVertex vertex = vertices[i];
406406

407407
sTMeshGeometry.vertices[i].Set(
408-
vertex.Anchor.X + vertex.Offset.X,
408+
vertex.Anchor.X + (vertex.CameraFacing ? -vertex.Offset.X : vertex.Offset.X),
409409
vertex.Anchor.Y + vertex.Offset.Y,
410410
vertex.Anchor.Z + vertex.Offset.Z);
411411

412412
sTMeshGeometry.vertices[i] *= m_MeshSettings.scaleFactor;
413413

414-
if (vertex.CameraFacing)
415-
{
416-
sTMeshGeometry.vertices[i].x = vertex.Anchor.X - vertex.Offset.X;
417-
}
418-
419414
sTMeshGeometry.normals[i].Set(vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z);
420415

421416
Vector3 vertexTangent = new Vector3(vertex.Tangent.X, vertex.Tangent.Y, vertex.Tangent.Z);
@@ -1264,6 +1259,7 @@ bool RippleHasAllCurvesValid(in WindRipple r)
12641259
// st9
12651260
cfg.branch1StretchLimit = wind.Branch1StretchLimit * scaleFactor;
12661261
cfg.branch2StretchLimit = wind.Branch2StretchLimit * scaleFactor;
1262+
cfg.importScale = scaleFactor;
12671263
cfg.treeExtentX = (treeBounds.Max.X - treeBounds.Min.X) * scaleFactor;
12681264
cfg.treeExtentY = (treeBounds.Max.Y - treeBounds.Min.Y) * scaleFactor;
12691265
cfg.treeExtentZ = (treeBounds.Max.Z - treeBounds.Min.Z) * scaleFactor;
@@ -1277,7 +1273,7 @@ bool RippleHasAllCurvesValid(in WindRipple r)
12771273
CopyCurve(shared.Turbulence, cfg.turbulenceShared);
12781274
CopyCurve(shared.Flexibility, cfg.flexibilityShared);
12791275
cfg.independenceShared = shared.Independence;
1280-
cfg.sharedHeightStart = wind.SharedStartHeight * scaleFactor;
1276+
cfg.sharedHeightStart = wind.SharedStartHeight; // this is a % value
12811277
if (BranchHasAllCurvesValid(in shared))
12821278
{
12831279
cfg.doShared = 1;
@@ -1347,29 +1343,25 @@ private void SetWindParameters(ref SpeedTreeWindConfig9 cfg)
13471343
#region Others
13481344
private void CalculateScaleFactorFromUnit()
13491345
{
1350-
float scaleFactor = m_MeshSettings.scaleFactor;
1351-
13521346
switch (m_MeshSettings.unitConversion)
13531347
{
13541348
// Use units in the imported file without any conversion.
13551349
case STUnitConversion.kLeaveAsIs:
1356-
scaleFactor = 1.0f;
1350+
m_MeshSettings.scaleFactor = 1.0f;
13571351
break;
13581352
case STUnitConversion.kFeetToMeters:
1359-
scaleFactor = SpeedTreeConstants.kFeetToMetersRatio;
1353+
m_MeshSettings.scaleFactor = SpeedTreeConstants.kFeetToMetersRatio;
13601354
break;
13611355
case STUnitConversion.kCentimetersToMeters:
1362-
scaleFactor = SpeedTreeConstants.kCentimetersToMetersRatio;
1356+
m_MeshSettings.scaleFactor = SpeedTreeConstants.kCentimetersToMetersRatio;
13631357
break;
13641358
case STUnitConversion.kInchesToMeters:
1365-
scaleFactor = SpeedTreeConstants.kInchesToMetersRatio;
1359+
m_MeshSettings.scaleFactor = SpeedTreeConstants.kInchesToMetersRatio;
13661360
break;
13671361
case STUnitConversion.kCustomConversion:
13681362
/* no-op */
13691363
break;
13701364
}
1371-
1372-
m_MeshSettings.scaleFactor = scaleFactor;
13731365
}
13741366

13751367
private bool TreeHasFacingData()

Editor/Mono/AssetPipeline/TextureImporter.bindings.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,30 @@ public void ReadTextureSettings(TextureImporterSettings dest)
452452
// Set texture importers settings from [[TextureImporterSettings]] class.
453453
public void SetTextureSettings(TextureImporterSettings src)
454454
{
455+
ValidateAndCorrectTextureImporterSettings(src);
455456
settings = src;
456457
}
457458

459+
private void ValidateAndCorrectTextureImporterSettings(TextureImporterSettings m_Settings)
460+
{
461+
switch (m_Settings.textureType)
462+
{
463+
case TextureImporterType.Sprite:
464+
m_Settings.npotScale = ValidateAndCorrectSetting(m_Settings.npotScale, TextureImporterNPOTScale.None, nameof(m_Settings.npotScale));
465+
break;
466+
}
467+
}
468+
469+
private T ValidateAndCorrectSetting<T>(T actual, T expected, string settingName)
470+
{
471+
if (!actual.Equals(expected))
472+
{
473+
Debug.LogWarning($"You cannot set {settingName} to {actual} for this texture type. It has been reset to {expected}.");
474+
return expected;
475+
}
476+
return actual;
477+
}
478+
458479
private extern TextureImporterSettings settings { get; set; }
459480

460481
[NativeName("GetImportInspectorWarning")]

Editor/Mono/Audio/AudioContainerWindowState.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ void OnEditorPlayModeStateChanged(PlayModeStateChange state)
341341

342342
void OnEditorPauseStateChanged(PauseState state)
343343
{
344+
if (m_AudioContainer == null || m_IsSuspended)
345+
{
346+
return;
347+
}
348+
344349
EditorPauseStateChanged?.Invoke(this, EventArgs.Empty);
345350
}
346351

Editor/Mono/BuildPipeline/NamedBuildTarget.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ namespace UnityEditor.Build
3434
"PS5",
3535
"EmbeddedLinux",
3636
"QNX",
37+
"ReservedCFE"
3738
};
3839

3940
public static readonly NamedBuildTarget Unknown = new NamedBuildTarget("");
@@ -121,6 +122,8 @@ public static NamedBuildTarget FromBuildTargetGroup(BuildTargetGroup buildTarget
121122
return new NamedBuildTarget("GameCoreXboxOne");
122123
case BuildTargetGroup.PS5:
123124
return new NamedBuildTarget("PS5");
125+
case BuildTargetGroup.ReservedCFE:
126+
return new NamedBuildTarget("ReservedCFE");
124127
}
125128

126129
throw new ArgumentException($"There is no a valid NamedBuildTarget for BuildTargetGroup '{buildTargetGroup}'");

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ static Styles()
157157
[UsedImplicitly, RequiredByNativeCode]
158158
public static void ShowBuildPlayerWindow()
159159
{
160-
EditorUserBuildSettings.selectedBuildTargetGroup = EditorUserBuildSettings.activeBuildTargetGroup;
161-
GetWindow<BuildPlayerWindow>(false, "Build Settings");
160+
BuildPipeline.ShowBuildProfileWindow();
162161
}
163162

164163
internal static bool WillDrawMultiplayerBuildOptions() => drawingMultiplayerBuildOptions != null;

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ internal BuildProfile activeProfile
8989
Save();
9090
EditorUserBuildSettings.SetBuildProfilePath(string.Empty);
9191
activeProfileChanged?.Invoke(prev, m_ActiveProfile);
92+
OnActiveProfileChangedForSettingExtension(prev, null);
9293
BuildProfileModuleUtil.RequestScriptCompilation(null);
9394
return;
9495
}
@@ -104,11 +105,22 @@ internal BuildProfile activeProfile
104105
Save();
105106
EditorUserBuildSettings.SetBuildProfilePath(AssetDatabase.GetAssetPath(m_ActiveProfile));
106107
activeProfileChanged?.Invoke(prev, m_ActiveProfile);
108+
OnActiveProfileChangedForSettingExtension(prev, m_ActiveProfile);
107109
m_ActiveProfile.UpdateGlobalManagerPlayerSettings();
108110
BuildProfileModuleUtil.RequestScriptCompilation(m_ActiveProfile);
109111
}
110112
}
111113

114+
void OnActiveProfileChangedForSettingExtension(BuildProfile previous, BuildProfile newProfile)
115+
{
116+
BuildTargetDiscovery.TryGetBuildTarget(EditorUserBuildSettings.activeBuildTarget, out IBuildTarget iBuildTarget);
117+
if (iBuildTarget == null)
118+
return;
119+
120+
var settingsExtension = ModuleManager.GetEditorSettingsExtension(iBuildTarget.TargetName);
121+
settingsExtension?.OnActiveProfileChanged(previous, newProfile);
122+
}
123+
112124
internal static void HandlePendingChangesBeforeEnterPlaymode()
113125
{
114126
if (!EditorUserBuildSettings.isBuildProfileAvailable)
@@ -466,8 +478,6 @@ BuildProfile GetOrCreateClassicPlatformBuildProfile(string platformId)
466478
Debug.LogError($"Build profile extension is null for module {module} and build profile {buildProfile.name}");
467479
}
468480

469-
SaveBuildProfileInProject(buildProfile);
470-
471481
return buildProfile;
472482
}
473483

@@ -491,8 +501,6 @@ BuildProfile GetOrCreateSharedBuildProfile()
491501
// when copying the settings.
492502
EditorUserBuildSettings.CopyToBuildProfile(buildProfile);
493503

494-
SaveBuildProfileInProject(buildProfile);
495-
496504
return buildProfile;
497505
}
498506

@@ -569,6 +577,8 @@ static void CreateOrLoad()
569577
s_Instance.cachedEditorScriptingDefines = BuildDefines.GetBuildProfileScriptDefines();
570578

571579
BuildProfileModuleUtil.DeleteLastRunnableBuildKeyForDeletedProfiles();
580+
581+
s_Instance.OnActiveProfileChangedForSettingExtension(null, s_Instance.m_ActiveProfile);
572582
}
573583

574584
[RequiredByNativeCode, UsedImplicitly]

Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ internal class BuildProfileModuleUtil
3939
public static string GetClassicPlatformDisplayName(string platformId) =>
4040
GetModuleDisplayName(platformId);
4141

42+
/// <summary>
43+
/// Platform description.
44+
/// </summary>
45+
public static string GetPlatformDescription(string platformGuid) =>
46+
BuildTargetDiscovery.BuildPlatformDescription(new GUID(platformGuid));
47+
4248
/// <summary>
4349
/// Fetch default editor platform icon texture.
4450
/// </summary>

Editor/Mono/BuildTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public enum BuildTarget
141141
QNX = 46,
142142

143143
VisionOS = 47,
144+
ReservedCFE = 48,
144145

145146
// obsolete identifiers. We're using different values so that ToString() works.
146147
[System.Obsolete("Use iOS instead (UnityUpgradable) -> iOS", true)]

0 commit comments

Comments
 (0)