Skip to content

Commit 77b37cd

Browse files
author
Unity Technologies
committed
Unity 6000.0.11f1 C# reference source code
1 parent 5406f17 commit 77b37cd

File tree

71 files changed

+1583
-657
lines changed

Some content is hidden

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

71 files changed

+1583
-657
lines changed

Editor/Mono/BuildProfile/BuildProfile.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static void ContextMenuReset(MenuCommand menuCommand)
228228

229229
AssetDatabase.SaveAssetIfDirty(targetBuildProfile);
230230
}
231-
231+
232232
void ValidateDataConsistency()
233233
{
234234
// TODO: Remove migration code (https://jira.unity3d.com/browse/PLAT-8909)
@@ -279,7 +279,10 @@ void CheckSceneListConsistency()
279279
scene.path = AssetDatabase.GUIDToAssetPath(scene.guid);
280280
}
281281

282-
if (string.IsNullOrEmpty(scene.path))
282+
283+
// Asset may have been deleted.
284+
// AssetDatabase may cache GUID to/from path mapping.
285+
if (string.IsNullOrEmpty(scene.path) || !AssetDatabase.AssetPathExists(scene.path))
283286
{
284287
// Scene Object may have been deleted from disk.
285288
RemoveAt(i);
@@ -288,11 +291,6 @@ void CheckSceneListConsistency()
288291

289292
if (!isGuidValid)
290293
scene.guid = AssetDatabase.GUIDFromAssetPath(scene.path);
291-
292-
// Asset may have been deleted. AssetDatabase may cache GUID to/from
293-
// path mapping.
294-
if (AssetDatabase.GetMainAssetTypeFromGUID(scene.guid) is null)
295-
RemoveAt(i);
296294
}
297295

298296
if (length == m_Scenes.Length)

Editor/Mono/EditorGUI.RenderPipeline.cs

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5-
using System.Collections.Generic;
6-
using System.Diagnostics.CodeAnalysis;
7-
using UnityEditor.Rendering;
5+
using UnityEditor.Rendering;
86
using UnityEngine;
97

108
namespace UnityEditor
119
{
12-
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
1310
public partial class EditorGUI
1411
{
15-
private static readonly int s_RenderingLayerMaskField = "s_RenderingLayerMaskField".GetHashCode();
12+
static readonly int s_RenderingLayerMaskField = nameof(s_RenderingLayerMaskField).GetHashCode();
1613

1714
// Make a field for rendering layer masks.
1815
public static void RenderingLayerMaskField(Rect position, string label, SerializedProperty property)
@@ -47,29 +44,47 @@ public static RenderingLayerMask RenderingLayerMaskField(Rect position, GUIConte
4744

4845
static uint RenderingLayerMaskFieldInternal(Rect position, GUIContent label, uint layers, SerializedProperty property, GUIStyle style)
4946
{
50-
var id = GUIUtility.GetControlID(s_RenderingLayerMaskField, FocusType.Keyboard, position);
51-
if (label != null)
52-
position = PrefixLabel(position, id, label);
53-
5447
var (names, values) = RenderPipelineEditorUtility.GetRenderingLayerNamesAndValuesForMask(layers);
55-
56-
using var scope = new MixedValueScope();
48+
var bitCount = RenderPipelineEditorUtility.GetActiveMaxRenderingLayers();
5749

5850
BeginChangeCheck();
59-
var newValue = MaskFieldGUI.DoMaskField(position, id, unchecked((int)layers), names, values, style);
60-
if (EndChangeCheck() && property != null)
51+
var mixedValue = property is { hasMultipleDifferentValues: true };
52+
var newValue = DrawMaskField(position, label, layers, names, values, style, mixedValue, !RenderPipelineEditorUtility.DoesMaskContainRenderingLayersOutsideOfMaxBitCount(layers, bitCount));
53+
var uintValue = unchecked((uint)newValue);
54+
55+
if (EndChangeCheck())
6156
{
62-
var bits = property.FindPropertyRelative("m_Bits");
63-
Debug.Assert(bits != null, $"Property for RenderingLayerMask doesn't contain m_Bits. You should use new {nameof(RenderingLayerMask)} type with this drawer.");
64-
bits.uintValue = (uint)newValue;
57+
if (uintValue != uint.MaxValue && BitOperationUtils.AreAllBitsSetForValues(uintValue, values, bitCount))
58+
uintValue = uint.MaxValue;
59+
60+
if(property != null)
61+
ApplyModifiedProperties(property, uintValue);
6562
}
6663

67-
var currentLimit = RenderPipelineEditorUtility.GetActiveMaxRenderingLayers();
68-
var newValueUint = unchecked((uint)newValue);
69-
if (currentLimit != 32 && newValueUint != uint.MaxValue && newValueUint >= 1u << currentLimit)
70-
EditorGUILayout.HelpBox($"Current mask contains layers outside of a supported range by active Render Pipeline. The active Render Pipeline only supports up to {currentLimit} layers. Rendering Layers above {currentLimit} are ignored.", MessageType.Warning);
64+
if (RenderPipelineEditorUtility.DoesMaskContainRenderingLayersOutsideOfMaxBitCount(uintValue, bitCount))
65+
EditorGUILayout.HelpBox(RenderPipelineEditorUtility.GetOutsideOfMaxBitCountWarningMessage(bitCount), MessageType.Warning);
66+
67+
return uintValue;
68+
}
69+
70+
static int DrawMaskField(Rect position, GUIContent label, uint layers, string[] names, int[] values, GUIStyle style, bool mixedValue, bool autoSelectEverything)
71+
{
72+
var id = GUIUtility.GetControlID(s_RenderingLayerMaskField, FocusType.Keyboard, position);
73+
if (label != null)
74+
position = PrefixLabel(position, id, label);
7175

72-
return unchecked((uint)newValue);
76+
using var scope = new MixedValueScope(mixedValue);
77+
78+
return MaskFieldGUI.DoMaskField(position, id, unchecked((int)layers), names, values, style, autoSelectEverything: autoSelectEverything);
79+
}
80+
81+
static void ApplyModifiedProperties(SerializedProperty property, uint uintValue)
82+
{
83+
var bits = property.FindPropertyRelative("m_Bits");
84+
Debug.Assert(bits != null, $"Property for RenderingLayerMask doesn't contain m_Bits. You should use new {nameof(RenderingLayerMask)} type with this drawer.");
85+
bits.uintValue = uintValue;
86+
property.serializedObject.ApplyModifiedProperties();
87+
property.serializedObject.SetIsDifferentCacheDirty();
7388
}
7489
}
7590
}

Editor/Mono/EditorGUI.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Linq;
2424
using System.Reflection;
2525
using Unity.Profiling;
26+
using UnityEditor.Rendering;
2627
using UnityEngine.Experimental.Rendering;
2728
using UnityEngine.UIElements;
2829
using UnityEditor.UIElements;

Editor/Mono/GI/ProbeIntegrator.bindings.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public override string ToString()
4343
public void Prepare(IDeviceContext context, IWorld world, BufferSlice<Vector3> positions, float pushoff, int bounceCount);
4444
public void SetProgressReporter(BakeProgressState progress);
4545
public Result IntegrateDirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount,
46-
bool ignoreDirectEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut);
46+
bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut);
4747
public Result IntegrateIndirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount,
48-
bool ignoreIndirectEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut);
48+
bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut);
4949
public Result IntegrateValidity(IDeviceContext context, int positionOffset, int positionCount, int sampleCount, BufferSlice<float> validityEstimateOut);
5050
public Result IntegrateOcclusion(IDeviceContext context, int positionOffset, int positionCount, int sampleCount,
5151
int maxLightsPerProbe, BufferSlice<int> perProbeLightIndices, BufferSlice<float> probeOcclusionEstimateOut);
@@ -76,7 +76,7 @@ public void SetProgressReporter(BakeProgressState progress)
7676
_progress = progress;
7777
}
7878
public unsafe IProbeIntegrator.Result IntegrateDirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount,
79-
bool ignoreDirectEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
79+
bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
8080
{
8181
Debug.Assert(context is WintermuteContext, "Expected WintermuteContext but got something else.");
8282
var wmContext = context as WintermuteContext;
@@ -94,7 +94,8 @@ public unsafe IProbeIntegrator.Result IntegrateDirectRadiance(IDeviceContext con
9494
int directSampleCount = sampleCount;
9595
int giSampleCount = 0;
9696
int envSampleCount = 0;
97-
const bool ignoreIndirectEnvironment = true;
97+
bool ignoreDirectEnvironment = ignoreEnvironment;
98+
bool ignoreIndirectEnvironment = ignoreEnvironment;
9899
var lightBakerResult = LightBaker.IntegrateProbeDirectRadianceWintermute(positionsPtr, _integrationContext, positionCount, _pushoff,
99100
_bounceCount, directSampleCount, giSampleCount, envSampleCount, ignoreDirectEnvironment, ignoreIndirectEnvironment, wmContext, _progress, shPtr);
100101

@@ -113,7 +114,7 @@ public unsafe IProbeIntegrator.Result IntegrateDirectRadiance(IDeviceContext con
113114
return lightBakerResult.ConvertToIProbeIntegratorResult();
114115
}
115116
public unsafe IProbeIntegrator.Result IntegrateIndirectRadiance(IDeviceContext context,
116-
int positionOffset, int positionCount, int sampleCount, bool ignoreIndirectEnvironment,
117+
int positionOffset, int positionCount, int sampleCount, bool ignoreEnvironment,
117118
BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
118119
{
119120
Debug.Assert(context is WintermuteContext, "Expected WintermuteContext but got something else.");
@@ -130,9 +131,10 @@ public unsafe IProbeIntegrator.Result IntegrateIndirectRadiance(IDeviceContext c
130131
using var radianceBuffer = new NativeArray<Rendering.SphericalHarmonicsL2>(positionCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
131132
void* shPtr = NativeArrayUnsafeUtility.GetUnsafePtr(radianceBuffer);
132133
int directSampleCount = 0;
133-
const bool ignoreDirectEnvironment = false;
134+
bool ignoreDirectEnvironment = ignoreEnvironment;
135+
bool ignoreIndirectEnvironment = ignoreEnvironment;
134136
int giSampleCount = sampleCount;
135-
int envSampleCount = ignoreIndirectEnvironment ? 0 : sampleCount;
137+
int envSampleCount = sampleCount;
136138
var lightBakerResult = LightBaker.IntegrateProbeIndirectRadianceWintermute(positionsPtr, _integrationContext, positionCount, _pushoff,
137139
_bounceCount, directSampleCount, giSampleCount, envSampleCount, ignoreDirectEnvironment, ignoreIndirectEnvironment, wmContext, _progress, shPtr);
138140

@@ -262,7 +264,7 @@ public void SetProgressReporter(BakeProgressState progress)
262264
_progress = progress;
263265
}
264266
public unsafe IProbeIntegrator.Result IntegrateDirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount,
265-
bool ignoreDirectEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
267+
bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
266268
{
267269
Debug.Assert(context is RadeonRaysContext, "Expected RadeonRaysContext but got something else.");
268270
var rrContext = context as RadeonRaysContext;
@@ -280,7 +282,8 @@ public unsafe IProbeIntegrator.Result IntegrateDirectRadiance(IDeviceContext con
280282
int directSampleCount = sampleCount;
281283
int giSampleCount = 0;
282284
int envSampleCount = 0;
283-
const bool ignoreIndirectEnvironment = true;
285+
bool ignoreDirectEnvironment = ignoreEnvironment;
286+
bool ignoreIndirectEnvironment = ignoreEnvironment;
284287
var lightBakerResult = LightBaker.IntegrateProbeDirectRadianceRadeonRays(positionsPtr, _integrationContext, positionCount, _pushoff,
285288
_bounceCount, directSampleCount, giSampleCount, envSampleCount, ignoreDirectEnvironment, ignoreIndirectEnvironment, rrContext, _progress, shPtr);
286289

@@ -300,7 +303,7 @@ public unsafe IProbeIntegrator.Result IntegrateDirectRadiance(IDeviceContext con
300303
}
301304

302305
public unsafe IProbeIntegrator.Result IntegrateIndirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount,
303-
bool ignoreIndirectEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
306+
bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
304307
{
305308
Debug.Assert(context is RadeonRaysContext, "Expected RadeonRaysContext but got something else.");
306309
var rrContext = context as RadeonRaysContext;
@@ -316,9 +319,10 @@ public unsafe IProbeIntegrator.Result IntegrateIndirectRadiance(IDeviceContext c
316319
using var radianceBuffer = new NativeArray<Rendering.SphericalHarmonicsL2>(positionCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
317320
void* shPtr = NativeArrayUnsafeUtility.GetUnsafePtr(radianceBuffer);
318321
int directSampleCount = 0;
319-
const bool ignoreDirectEnvironment = false;
322+
bool ignoreDirectEnvironment = ignoreEnvironment;
323+
bool ignoreIndirectEnvironment = ignoreEnvironment;
320324
int giSampleCount = sampleCount;
321-
int envSampleCount = ignoreIndirectEnvironment ? 0 : sampleCount;
325+
int envSampleCount = sampleCount;
322326
var lightBakerResult = LightBaker.IntegrateProbeIndirectRadianceRadeonRays(positionsPtr, _integrationContext, positionCount, _pushoff,
323327
_bounceCount, directSampleCount, giSampleCount, envSampleCount, ignoreDirectEnvironment, ignoreIndirectEnvironment, rrContext, _progress, shPtr);
324328

Editor/Mono/GUI/MaskFieldGUI.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,27 @@ public void UpdateFlagChanges(int controlID, int mask, int[] optionMaskValues)
111111
}
112112

113113
/// Make a field for a generic mask.
114-
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style)
114+
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style, bool autoSelectEverything = true)
115115
{
116116
int dummyInt;
117117
bool dummyBool;
118-
return DoMaskField(position, controlID, mask, flagNames, style, out dummyInt, out dummyBool);
118+
return DoMaskField(position, controlID, mask, flagNames, style, out dummyInt, out dummyBool, autoSelectEverything);
119119
}
120120

121-
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style)
121+
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style, bool autoSelectEverything = true)
122122
{
123123
int dummyInt;
124124
bool dummyBool;
125-
return DoMaskField(position, controlID, mask, flagNames, flagValues, style, out dummyInt, out dummyBool);
125+
return DoMaskField(position, controlID, mask, flagNames, flagValues, style, out dummyInt, out dummyBool, autoSelectEverything: autoSelectEverything);
126126
}
127127

128-
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style, out int changedFlags, out bool changedToValue)
128+
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style, out int changedFlags, out bool changedToValue, bool autoSelectEverything = true)
129129
{
130130
var flagValues = new int[flagNames.Length];
131131
for (int i = 0; i < flagValues.Length; ++i)
132132
flagValues[i] = (1 << i);
133133

134-
return DoMaskField(position, controlID, mask, flagNames, flagValues, style, out changedFlags, out changedToValue);
134+
return DoMaskField(position, controlID, mask, flagNames, flagValues, style, out changedFlags, out changedToValue, autoSelectEverything: autoSelectEverything);
135135
}
136136

137137
internal static void DestroyMaskCallBackInfo()
@@ -142,11 +142,11 @@ internal static void DestroyMaskCallBackInfo()
142142
/// Make a field for a generic mask.
143143
/// This version also gives you back which flags were changed and what they were changed to.
144144
/// This is useful if you want to make the same change to multiple objects.
145-
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style, out int changedFlags, out bool changedToValue, Type enumType = null)
145+
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style, out int changedFlags, out bool changedToValue, Type enumType = null, bool autoSelectEverything = true)
146146
{
147147
mask = MaskCallbackInfo.GetSelectedValueForControl(controlID, mask, out changedFlags, out changedToValue);
148148

149-
GetMenuOptions(mask, flagNames, flagValues, out var buttonText, out var buttonTextMixed, out var optionNames, out var optionMaskValues, out _, enumType);
149+
GetMenuOptions(mask, flagNames, flagValues, out var buttonText, out var buttonTextMixed, out var optionNames, out var optionMaskValues, out _, enumType, autoSelectEverything);
150150

151151
// This checks and update flags changes that are modified out of dropdown menu
152152
if (MaskCallbackInfo.m_Instance != null)
@@ -161,7 +161,7 @@ internal static int DoMaskField(Rect position, int controlID, int mask, string[]
161161
else if ((evt.type == EventType.MouseDown && position.Contains(evt.mousePosition)) || evt.MainActionKeyForControl(controlID))
162162
{
163163
MaskCallbackInfo.m_Instance = new MaskCallbackInfo(controlID);
164-
MaskCallbackInfo.m_Instance.m_DropDown = new MaskFieldDropDown(optionNames, flagValues, optionMaskValues, mask, MaskCallbackInfo.m_Instance.SetMaskValueDelegate);
164+
MaskCallbackInfo.m_Instance.m_DropDown = new MaskFieldDropDown(optionNames, flagValues, optionMaskValues, mask, MaskCallbackInfo.m_Instance.SetMaskValueDelegate, autoSelectEverything);
165165
PopupWindowWithoutFocus.Show(position, MaskCallbackInfo.m_Instance.m_DropDown);
166166
}
167167

@@ -304,7 +304,7 @@ internal static void CalculateMaskValues(int mask, int[] flagValues, ref int[] o
304304
}
305305

306306
internal static void GetMenuOptions(int mask, string[] flagNames, int[] flagValues,
307-
out string buttonText, out string buttonMixedValuesText, out string[] optionNames, out int[] optionMaskValues, out int[] selectedOptions, Type enumType = null)
307+
out string buttonText, out string buttonMixedValuesText, out string[] optionNames, out int[] optionMaskValues, out int[] selectedOptions, Type enumType = null, bool autoSelectEverything = true)
308308
{
309309
const int everythingValue = ~0;
310310
bool hasNothingName = flagValues[0] == 0;
@@ -361,7 +361,7 @@ internal static void GetMenuOptions(int mask, string[] flagNames, int[] flagValu
361361

362362
if (buttonText == null)
363363
{
364-
if (flagMask == intermediateMask)
364+
if (flagMask == intermediateMask && autoSelectEverything)
365365
{
366366
// If all of the available flags are set then show the Everything name.
367367
s_SelectedOptionsSet.Add(1);

Editor/Mono/Inspector/Core/AddComponent/AddComponentWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected override void OnEnable()
6464

6565
private void OnItemSelected(AdvancedDropdownItem item)
6666
{
67-
if (item is ComponentDropdownItem cdi)
67+
if (item is ComponentDropdownItem cdi && !string.IsNullOrEmpty(cdi.menuPath))
6868
{
6969
SendUsabilityAnalyticsEvent(new AnalyticsEventData
7070
{

0 commit comments

Comments
 (0)