Skip to content

Commit 0782d04

Browse files
author
Unity Technologies
committed
Unity 6000.0.16f1 C# reference source code
1 parent 73c16d0 commit 0782d04

Some content is hidden

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

52 files changed

+1212
-512
lines changed

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ internal static BuildProfileContext instance
166166
}
167167
}
168168

169-
internal IList<BuildProfile> classicPlatformProfiles
169+
// Note: this has to be a serializable type such as List<T>, so that
170+
// the references to classic build profiles survive domain reloads
171+
internal List<BuildProfile> classicPlatformProfiles
170172
{
171173
[VisibleToOtherModules]
172174
get;
@@ -352,45 +354,58 @@ void OnEnable()
352354
EditorApplication.quitting -= SyncActiveProfileToFallback;
353355
EditorApplication.quitting += SyncActiveProfileToFallback;
354356

355-
classicPlatformProfiles = new List<BuildProfile>();
356-
357-
// Load platform build profiles from ProjectSettings folder.
358-
if (!Directory.Exists(k_BuildProfilePath))
359-
return;
360-
361-
var viewablePlatformKeys = BuildProfileModuleUtil.FindAllViewablePlatforms();
362-
for (var index = 0; index < viewablePlatformKeys.Count; index++)
357+
if (classicPlatformProfiles != null && classicPlatformProfiles.Count > 0)
363358
{
364-
var key = viewablePlatformKeys[index];
365-
string path = GetFilePathForBuildProfile(key);
359+
// classicPlatformProfiles survived the domain reload - just readd them to the classic profile map
360+
foreach (var profileObj in classicPlatformProfiles)
361+
m_PlatformIdToClassicPlatformProfile.Add(profileObj.platformId, profileObj);
362+
}
363+
else
364+
{
365+
// first load - populate classic profiles from disk
366+
classicPlatformProfiles = new List<BuildProfile>();
366367

367-
if (!File.Exists(path) || !BuildProfileModuleUtil.IsModuleInstalled(key))
368-
continue;
368+
// Load platform build profiles from ProjectSettings folder.
369+
if (!Directory.Exists(k_BuildProfilePath))
370+
return;
369371

370-
var profile = InternalEditorUtility.LoadSerializedFileAndForget(path);
371-
if (profile == null || profile.Length == 0 || profile[0] is not BuildProfile profileObj)
372+
var viewablePlatformKeys = BuildProfileModuleUtil.FindAllViewablePlatforms();
373+
for (var index = 0; index < viewablePlatformKeys.Count; index++)
372374
{
373-
Debug.LogWarning($"Failed to load build profile from {path}.");
374-
continue;
375-
}
375+
var key = viewablePlatformKeys[index];
376+
string path = GetFilePathForBuildProfile(key);
376377

377-
m_PlatformIdToClassicPlatformProfile.Add(profileObj.platformId, profileObj);
378-
classicPlatformProfiles.Add(profileObj);
379-
}
378+
if (!File.Exists(path) || !BuildProfileModuleUtil.IsModuleInstalled(key))
379+
continue;
380380

381-
if (!File.Exists(k_SharedProfilePath))
382-
return;
381+
var profile = InternalEditorUtility.LoadSerializedFileAndForget(path);
382+
if (profile == null || profile.Length == 0 || profile[0] is not BuildProfile profileObj)
383+
{
384+
Debug.LogWarning($"Failed to load build profile from {path}.");
385+
continue;
386+
}
383387

384-
var sharedProfile = InternalEditorUtility.LoadSerializedFileAndForget(k_SharedProfilePath);
385-
if (sharedProfile == null || sharedProfile.Length == 0 || sharedProfile[0] is not BuildProfile sharedProfileObj)
386-
{
387-
Debug.LogWarning($"Failed to load shared profile from {k_SharedProfilePath}.");
388-
return;
388+
m_PlatformIdToClassicPlatformProfile.Add(profileObj.platformId, profileObj);
389+
classicPlatformProfiles.Add(profileObj);
390+
}
389391
}
390392

391-
instance.sharedProfile = sharedProfileObj;
393+
if (sharedProfile == null)
394+
{
395+
if (!File.Exists(k_SharedProfilePath))
396+
return;
397+
398+
var sharedProfileArray = InternalEditorUtility.LoadSerializedFileAndForget(k_SharedProfilePath);
399+
if (sharedProfileArray == null || sharedProfileArray.Length == 0 || sharedProfileArray[0] is not BuildProfile sharedProfileObj)
400+
{
401+
Debug.LogWarning($"Failed to load shared profile from {k_SharedProfilePath}.");
402+
return;
403+
}
392404

393-
var buildProfile = instance.activeProfile ?? GetForClassicPlatform(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.standaloneBuildSubtarget);
405+
sharedProfile = sharedProfileObj;
406+
}
407+
408+
var buildProfile = activeProfile ?? GetForClassicPlatform(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.standaloneBuildSubtarget);
394409

395410
// profile can be null if we're in the middle of creating classic profiles
396411
if (buildProfile == null)
@@ -689,6 +704,7 @@ static string GetLegacyFilePathForBuildProfile((string moduleName, StandaloneBui
689704
static void Save() => InternalEditorUtility.SaveToSerializedFileAndForget(new[] { instance },
690705
k_BuildProfileProviderAssetPath, true);
691706

707+
[VisibleToOtherModules]
692708
internal static bool IsSharedProfile(BuildTarget target) => target == BuildTarget.NoTarget;
693709
}
694710
}

Editor/Mono/EditorApplication.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ public static event Action<PlayModeStateChange> playModeStateChanged
278278

279279
// Global key up/down or mouse up/down/drag events that were not handled by anyone
280280
internal static CallbackFunction globalEventHandler;
281+
internal static CallbackFunction shortcutHelperBarEventHandler;
281282

282283
// Returns true when the pressed keys are defined in the Trigger
283284
internal static Func<bool> doPressedKeysTriggerAnyShortcut;
@@ -521,6 +522,7 @@ static bool DoPressedKeysTriggerAnyShortcutHandler()
521522
static void Internal_CallGlobalEventHandler()
522523
{
523524
globalEventHandler?.Invoke();
525+
shortcutHelperBarEventHandler?.Invoke();
524526

525527
// Ensure this is called last in order to make sure no null current events are passed to other handlers
526528
WindowLayout.MaximizeGestureHandler();

Editor/Mono/EditorGUIUtility.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,12 @@ public static GUIContent ObjectContent(UnityObject obj, Type type)
963963
return ObjectContent(obj, type, ReferenceEquals(obj, null) ? 0 : obj.GetInstanceID());
964964
}
965965

966-
internal static GUIContent ObjectContent(UnityObject obj, Type type, int instanceID)
966+
internal static GUIContent ObjectContent(UnityObject obj, Type type, bool showNullIcon)
967+
{
968+
return ObjectContent(obj, type, ReferenceEquals(obj, null) ? 0 : obj.GetInstanceID(), showNullIcon);
969+
}
970+
971+
internal static GUIContent ObjectContent(UnityObject obj, Type type, int instanceID, bool showNullIcon = true)
967972
{
968973
if (obj)
969974
{
@@ -973,7 +978,7 @@ internal static GUIContent ObjectContent(UnityObject obj, Type type, int instanc
973978
else if (type != null)
974979
{
975980
s_ObjectContent.text = GetTypeNameWithInfo(type.Name, instanceID);
976-
s_ObjectContent.image = null; // Do not show icon when the reference is null as the type is already included in the label (UUM-16396)
981+
s_ObjectContent.image = showNullIcon ? AssetPreview.GetMiniTypeThumbnail(type) : null;
977982
}
978983
else
979984
{
@@ -1006,9 +1011,9 @@ internal static GUIContent ObjectContent(UnityObject obj, Type type, SerializedP
10061011
// from property.objectReferenceValue is not reliable, so we have to
10071012
// explicitly check property.objectReferenceInstanceIDValue if a property exists.
10081013
if (property != null && property.isValid)
1009-
temp = ObjectContent(obj, type, property.objectReferenceInstanceIDValue);
1014+
temp = ObjectContent(obj, type, property.objectReferenceInstanceIDValue, false);
10101015
else
1011-
temp = ObjectContent(obj, type);
1016+
temp = ObjectContent(obj, type, false);
10121017
}
10131018

10141019
if (property != null && property.isValid)

Editor/Mono/EditorSettings.bindings.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,18 @@ internal static extern string Internal_ProjectGenerationUserExtensions
242242
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
243243
public static extern bool useLegacyProbeSampleCount { get; set; }
244244

245-
[Obsolete("EditorSettings.disableCookiesInLightmapper is obsolete, please use EditorSettings.enableCookiesInLightmapper instead.", false)]
246-
[StaticAccessor("GetEditorSettings()", StaticAccessorType.Dot)]
247-
public static extern bool disableCookiesInLightmapper { get; set; }
245+
[Obsolete("The disableCookiesInLightmapper setting is no longer supported. Cookies are always enabled in the Progressive Lightmapper.", true)]
246+
public static bool disableCookiesInLightmapper
247+
{
248+
get { return false; }
249+
set {}
250+
}
248251

252+
[Obsolete("The enableCookiesInLightmapper setting is no longer supported. Cookies are always enabled in the Progressive Lightmapper.")]
249253
public static bool enableCookiesInLightmapper
250254
{
251-
#pragma warning disable 618
252-
get { return !disableCookiesInLightmapper; }
253-
set { disableCookiesInLightmapper = !value; }
254-
#pragma warning restore 618
255+
get { return true; }
256+
set {}
255257
}
256258

257259
[Obsolete("Bake with the Progressive Lightmapper.The backend that uses Enlighten to bake is obsolete.", true)]

Editor/Mono/GI/InputExtraction.bindings.cs

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,34 @@ public static string LogInstances(LightBaker.BakeInput bakeInput, SourceMap map)
110110
else
111111
message += $" Instance [{i}] [{LookupGameObjectName(map, i)}]:\n";
112112
LightBaker.Instance instance = bakeInput.instance((uint)i);
113-
message += $" mesh type\t\t: {instance.meshType}\n";
113+
message += $" mesh type\t\t\t: {instance.meshType}\n";
114114
if (instance.meshType == LightBaker.MeshType.MeshRenderer)
115-
message += $" mesh index\t: {instance.meshIndex}\n";
115+
message += $" mesh index\t\t\t: {instance.meshIndex}\n";
116116
else if (instance.meshType == LightBaker.MeshType.Terrain)
117-
message += $" terrain index\t: {instance.terrainIndex}\n";
118-
message += $" transform\t\t: {instance.transform.GetRow(0)}\n";
119-
message += $" \t\t: {instance.transform.GetRow(1)}\n";
120-
message += $" \t\t: {instance.transform.GetRow(2)}\n";
121-
message += $" \t\t: {instance.transform.GetRow(3)}\n";
122-
message += $" cast shadows\t: {instance.castShadows}\n";
117+
message += $" terrain index\t\t: {instance.terrainIndex}\n";
118+
message += $" transform\t\t\t: {instance.transform.GetRow(0)}\n";
119+
message += $" \t\t\t: {instance.transform.GetRow(1)}\n";
120+
message += $" \t\t\t: {instance.transform.GetRow(2)}\n";
121+
message += $" \t\t\t: {instance.transform.GetRow(3)}\n";
122+
message += $" cast shadows\t\t: {instance.castShadows}\n";
123123
message += $" receive shadows\t: {instance.receiveShadows}\n";
124124
if (instance.meshType == LightBaker.MeshType.MeshRenderer)
125125
{
126-
message += $" odd negative scale\t: {instance.oddNegativeScale}\n";
127-
message += $" lod group\t\t: {instance.lodGroup}\n";
128-
message += $" lod mask\t\t: {instance.lodMask}\n";
126+
message += $" odd neg scale\t\t: {instance.oddNegativeScale}\n";
127+
message += $" lod group\t\t\t: {instance.lodGroup}\n";
128+
message += $" lod mask\t\t\t\t: {instance.lodMask}\n";
129129
}
130-
message += $" submesh count\t: {instance.submeshMaterialIndices.Length}\n";
130+
message += $" submesh count\t\t: {instance.submeshMaterialIndices.Length}\n";
131131
string indices = string.Empty;
132132
for (int j = 0; j < instance.submeshMaterialIndices.Length; ++j)
133133
indices += instance.submeshMaterialIndices[j] + (j < (instance.submeshMaterialIndices.Length - 1) ? ", " : "");
134134
message += $" submesh mat idxs\t: {{{indices}}}\n";
135+
message += $" albedo tex idx\t\t: {bakeInput.instanceToAlbedoIndex((uint)i)}\n";
136+
message += $" emissive tex idx\t: {bakeInput.instanceToEmissiveIndex((uint)i)}\n";
137+
string transmissiveIndices = string.Empty;
138+
for (int j = 0; j < instance.submeshMaterialIndices.Length; ++j)
139+
transmissiveIndices += bakeInput.instanceToTransmissiveIndex((uint)i, (uint)j) + (j < (instance.submeshMaterialIndices.Length - 1) ? ", " : "");
140+
message += $" trans tex idxs\t\t: {{{transmissiveIndices}}}\n";
135141
}
136142
return message;
137143
}
@@ -141,13 +147,13 @@ public static string LogSceneMaterials(LightBaker.BakeInput bakeInput)
141147
if (bakeInput is null)
142148
return string.Empty;
143149
string message = string.Empty;
144-
message += $" material count\t: {bakeInput.materialCount}\n";
150+
message += $" material count\t\t: {bakeInput.materialCount}\n";
145151
for (int i = 0; i < bakeInput.materialCount; ++i)
146152
{
147153
message += $" Material [{i}]:\n";
148-
message += $" doubleSidedGI\t: {bakeInput.GetMaterial((uint)i).doubleSidedGI}\n";
154+
message += $" doubleSidedGI\t\t\t: {bakeInput.GetMaterial((uint)i).doubleSidedGI}\n";
149155
message += $" transmissionChannels\t: {bakeInput.GetMaterial((uint)i).transmissionChannels}\n";
150-
message += $" transmissionType\t: {bakeInput.GetMaterial((uint)i).transmissionType}\n";
156+
message += $" transmissionType\t\t: {bakeInput.GetMaterial((uint)i).transmissionType}\n";
151157
}
152158
return message;
153159
}
@@ -181,22 +187,22 @@ public static string LogSceneLights(LightBaker.BakeInput bakeInput)
181187
{
182188
LightBaker.Light light = bakeInput.GetLight((uint)i);
183189
message += $" Light [{i}]:\n";
184-
message += $" color\t\t: {light.color}\n";
185-
message += $" indirect color\t: {light.indirectColor}\n";
186-
message += $" orientation\t: {light.orientation}\n";
187-
message += $" position\t\t: {light.position}\n";
188-
message += $" range\t\t: {light.range}\n";
189-
message += $" cookie index\t: {light.cookieTextureIndex}\n";
190-
message += $" cookie scale\t: {light.cookieScale}\n";
191-
message += $" cone angle\t: {light.coneAngle}\n";
190+
message += $" color\t\t\t\t\t: {light.color}\n";
191+
message += $" indirect color\t\t: {light.indirectColor}\n";
192+
message += $" orientation\t\t\t: {light.orientation}\n";
193+
message += $" position\t\t\t\t: {light.position}\n";
194+
message += $" range\t\t\t\t\t: {light.range}\n";
195+
message += $" cookie index\t\t: {light.cookieTextureIndex}\n";
196+
message += $" cookie scale\t\t: {light.cookieScale}\n";
197+
message += $" cone angle\t\t\t: {light.coneAngle}\n";
192198
message += $" inner cone angle\t: {light.innerConeAngle}\n";
193-
message += $" shape0\t\t: {light.shape0}\n";
194-
message += $" shape1\t\t: {light.shape1}\n";
195-
message += $" type\t\t: {light.type}\n";
196-
message += $" mode\t\t: {light.mode}\n";
197-
message += $" falloff\t\t: {light.falloff}\n";
199+
message += $" shape0\t\t\t\t: {light.shape0}\n";
200+
message += $" shape1\t\t\t\t: {light.shape1}\n";
201+
message += $" type\t\t\t\t\t: {light.type}\n";
202+
message += $" mode\t\t\t\t\t: {light.mode}\n";
203+
message += $" falloff\t\t\t\t: {light.falloff}\n";
198204
message += $" angular falloff\t: {light.angularFalloff}\n";
199-
message += $" casts shadows\t: {light.castsShadows}\n";
205+
message += $" casts shadows\t\t: {light.castsShadows}\n";
200206
message += $" shadowmask chnl\t: {light.shadowMaskChannel}\n";
201207
}
202208
return message;
@@ -222,12 +228,12 @@ public static string LogSceneSettings(LightBaker.BakeInput bakeInput)
222228
message += LogSampleCounts(lightingSettings.lightmapSampleCounts);
223229
message += $" lightprobe sample counts:\n";
224230
message += LogSampleCounts(lightingSettings.probeSampleCounts);
225-
message += $" min bounces\t: {lightingSettings.minBounces}\n";
226-
message += $" max bounces\t: {lightingSettings.maxBounces}\n";
231+
message += $" min bounces\t\t\t\t: {lightingSettings.minBounces}\n";
232+
message += $" max bounces\t\t\t\t: {lightingSettings.maxBounces}\n";
227233
message += $" lightmap bake mode\t: {lightingSettings.lightmapBakeMode}\n";
228234
message += $" mixed lighting mode\t: {lightingSettings.mixedLightingMode}\n";
229-
message += $" ao enabled\t\t: {lightingSettings.aoEnabled}\n";
230-
message += $" ao distance\t\t: {lightingSettings.aoDistance}\n";
235+
message += $" ao enabled\t\t\t\t: {lightingSettings.aoEnabled}\n";
236+
message += $" ao distance\t\t\t\t: {lightingSettings.aoDistance}\n";
231237
return message;
232238
}
233239

@@ -238,10 +244,10 @@ public static string LogScene(LightBaker.BakeInput bakeInput, LightBaker.Lightma
238244
string message = string.Empty;
239245
message += LogSceneSettings(bakeInput);
240246
message += LogInstances(bakeInput, map);
241-
message += $" mesh count\t\t: {bakeInput.meshCount}\n";
247+
message += $" mesh count\t\t\t: {bakeInput.meshCount}\n";
242248
message += $" terrain count\t\t: {bakeInput.terrainCount}\n";
243249
message += $" heightmap count\t: {bakeInput.heightmapCount}\n";
244-
message += $" holemap count\t: {bakeInput.holemapCount}\n";
250+
message += $" holemap count\t\t: {bakeInput.holemapCount}\n";
245251
message += LogSceneMaterials(bakeInput);
246252
message += $" albedo tex count\t: {bakeInput.albedoTextureCount}\n";
247253
for (int i = 0; i < bakeInput.albedoTextureCount; ++i)

Editor/Mono/GI/LightBaker.bindings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ public uint lightmapInstanceCount(uint index)
754754
extern uint Internal_LightmapHeight(uint index);
755755
extern uint Internal_InstanceCount(uint lightmapIndex);
756756
public extern void SetLightmapResolution(Resolution resolution);
757+
public extern void SetSingleLightmapResolution(uint index, Resolution resolution);
757758
public Resolution lightmapResolution(uint index)
758759
{
759760
if (index >= lightmapCount)

0 commit comments

Comments
 (0)