Skip to content

Commit cd07e25

Browse files
authored
Merge pull request #8281 from Unity-Technologies/internal/6000.4/staging
Mirror Internal/6000.4/staging
2 parents ee884d0 + 482c8f1 commit cd07e25

File tree

101 files changed

+7282
-1814
lines changed

Some content is hidden

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

101 files changed

+7282
-1814
lines changed

Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void IRenderPipelineGraphicsSettingsContextMenu2<TSetting>.PopulateContextMenu(T
132132
bool canCreateNewAsset = RenderPipelineManager.currentPipeline is TRenderPipeline;
133133
VolumeProfileUtils.AddVolumeProfileContextMenuItems(ref menu,
134134
setting.volumeProfile,
135-
s_DefaultVolumeProfileEditor.allEditors,
135+
s_DefaultVolumeProfileEditor == null ? null : s_DefaultVolumeProfileEditor.allEditors,
136136
overrideStateOnReset: true,
137137
defaultVolumeProfilePath: defaultVolumeProfilePath,
138138
onNewVolumeProfileCreated: createdProfile =>
@@ -151,7 +151,7 @@ void IRenderPipelineGraphicsSettingsContextMenu2<TSetting>.PopulateContextMenu(T
151151
}
152152
VolumeProfileUtils.UpdateGlobalDefaultVolumeProfile<TRenderPipeline>(createdProfile, initialAsset);
153153
},
154-
onComponentEditorsExpandedCollapsed: s_DefaultVolumeProfileEditor.RebuildListViews,
154+
onComponentEditorsExpandedCollapsed: s_DefaultVolumeProfileEditor == null ? null : s_DefaultVolumeProfileEditor.RebuildListViews,
155155
canCreateNewAsset);
156156
}
157157
}

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentEditor.cs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ internal void SetVolumeProfile(VolumeProfile p)
196196

197197
static Dictionary<Type, VolumeParameterDrawer> s_ParameterDrawers;
198198
SupportedOnRenderPipelineAttribute m_SupportedOnRenderPipelineAttribute;
199-
Type[] m_LegacyPipelineTypes;
200199

201200
static VolumeComponentEditor()
202201
{
@@ -274,11 +273,6 @@ internal void Init()
274273

275274
var volumeComponentType = volumeComponent.GetType();
276275
m_SupportedOnRenderPipelineAttribute = volumeComponentType.GetCustomAttribute<SupportedOnRenderPipelineAttribute>();
277-
278-
#pragma warning disable CS0618
279-
var supportedOn = volumeComponentType.GetCustomAttribute<VolumeComponentMenuForRenderPipeline>();
280-
m_LegacyPipelineTypes = supportedOn != null ? supportedOn.pipelineTypes : Array.Empty<Type>();
281-
#pragma warning restore CS0618
282276
}
283277

284278
internal void DetermineVisibility(Type renderPipelineAssetType, Type renderPipelineType)
@@ -295,12 +289,6 @@ internal void DetermineVisibility(Type renderPipelineAssetType, Type renderPipel
295289
return;
296290
}
297291

298-
if (renderPipelineType != null && m_LegacyPipelineTypes.Length > 0)
299-
{
300-
visible = m_LegacyPipelineTypes.Contains(renderPipelineType);
301-
return;
302-
}
303-
304292
visible = true;
305293
}
306294

@@ -440,24 +428,27 @@ public override void OnInspectorGUI()
440428
}
441429
}
442430

431+
GUIContent m_DisplayTitle;
443432
/// <summary>
444433
/// Sets the label for the component header. Override this method to provide
445434
/// a custom label. If you don't, Unity automatically obtains one from the class name.
446435
/// </summary>
447436
/// <returns>A label to display in the component header.</returns>
448437
public virtual GUIContent GetDisplayTitle()
449438
{
439+
if (m_DisplayTitle != null) return m_DisplayTitle;
440+
450441
var volumeComponentType = volumeComponent.GetType();
451442
var displayInfo = volumeComponentType.GetCustomAttribute<DisplayInfoAttribute>();
452443
if (displayInfo != null && !string.IsNullOrWhiteSpace(displayInfo.name))
453-
return EditorGUIUtility.TrTextContent(displayInfo.name, string.Empty);
454-
444+
return m_DisplayTitle = EditorGUIUtility.TrTextContent(displayInfo.name, string.Empty);
445+
455446
#pragma warning disable CS0618
456447
if (!string.IsNullOrWhiteSpace(volumeComponent.displayName))
457-
return EditorGUIUtility.TrTextContent(volumeComponent.displayName, string.Empty);
448+
return m_DisplayTitle = EditorGUIUtility.TrTextContent(volumeComponent.displayName, string.Empty);
458449
#pragma warning restore CS0618
459-
460-
return EditorGUIUtility.TrTextContent(ObjectNames.NicifyVariableName(volumeComponentType.Name) , string.Empty);
450+
451+
return m_DisplayTitle = EditorGUIUtility.TrTextContent(ObjectNames.NicifyVariableName(volumeComponentType.Name), string.Empty);
461452
}
462453

463454
void AddToggleState(GUIContent content, bool state)

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ void CreateEditor(VolumeComponent component, SerializedProperty property, int in
155155
else
156156
m_Editors[index] = editor;
157157

158+
FilterEditorsBySearch();
159+
158160
DocumentationUtils.TryGetHelpURL(component.GetType(), out string helpUrl);
159161
helpUrl ??= string.Empty;
160162
m_VolumeComponentHelpUrls[editor] = helpUrl;
@@ -222,9 +224,22 @@ public void Clear()
222224
asset = null;
223225
}
224226

227+
readonly HashSet<VolumeComponentEditor> m_CurrentSearchFilteredEditors = new();
228+
void FilterEditorsBySearch()
229+
{
230+
m_CurrentSearchFilteredEditors.Clear();
231+
if (string.IsNullOrEmpty(m_SearchString)) return;
232+
233+
foreach (var editor in m_Editors)
234+
{
235+
if (MatchesSearchString(editor.GetDisplayTitle().text))
236+
m_CurrentSearchFilteredEditors.Add(editor);
237+
}
238+
}
239+
bool EditorIsIncludedInCurrentSearch(VolumeComponentEditor editor) => string.IsNullOrEmpty(m_SearchString) || m_CurrentSearchFilteredEditors.Contains(editor);
225240
bool MatchesSearchString(string title)
226241
{
227-
return m_SearchString.Length == 0 || title.Contains(m_SearchString, StringComparison.OrdinalIgnoreCase);
242+
return string.IsNullOrEmpty(m_SearchString) || title.Contains(m_SearchString, StringComparison.OrdinalIgnoreCase);
228243
}
229244

230245
/// <summary>
@@ -263,7 +278,7 @@ bool ShouldDrawEditor(VolumeComponentEditor editor)
263278
{
264279
if (!editor.visible)
265280
return false;
266-
return MatchesSearchString(editor.GetDisplayTitle().text);
281+
return EditorIsIncludedInCurrentSearch(editor);
267282
}
268283

269284
void DrawEditor(VolumeComponentEditor editor, int index = -1)
@@ -310,7 +325,11 @@ void DrawEditor(VolumeComponentEditor editor, int index = -1)
310325
{
311326
Rect searchRect = GUILayoutUtility.GetRect(50, EditorGUIUtility.singleLineHeight);
312327
searchRect.width -= 2;
313-
m_SearchString = m_SearchField.OnGUI(searchRect, m_SearchString);
328+
using (var check = new EditorGUI.ChangeCheckScope())
329+
{
330+
m_SearchString = m_SearchField.OnGUI(searchRect, m_SearchString);
331+
if (check.changed) FilterEditorsBySearch();
332+
}
314333
GUILayout.Space(2);
315334

316335
EditorGUILayout.HelpBox(
@@ -346,7 +365,6 @@ void DrawEditor(VolumeComponentEditor editor, int index = -1)
346365

347366
for (int i = 0; i < editors.Count; i++)
348367
DrawEditor(editors[i]);
349-
350368
GUILayout.Space(8);
351369
}
352370
}

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileUtils.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ static VolumeComponent GetVolumeComponentOfTypeOrDefault(this VolumeProfile prof
140140
static List<Type> GetTypesMissingFromDefaultProfile(VolumeProfile profile)
141141
{
142142
List<Type> missingTypes = new List<Type>();
143-
var volumeComponentTypes = VolumeManager.instance.baseComponentTypeArray;
143+
144+
var volumeComponentTypes = VolumeManager.instance.isInitialized ?
145+
VolumeManager.instance.baseComponentTypeArray : VolumeManager.instance.LoadBaseTypesByReflection(GraphicsSettings.currentRenderPipelineAssetType);
144146
foreach (var type in volumeComponentTypes)
145147
{
146148
if (profile.components.Find(c => c.GetType() == type) == null)
147149
{
148-
if (type.IsDefined(typeof(ObsoleteAttribute), false) ||
149-
type.IsDefined(typeof(HideInInspector), false))
150+
if (type.IsDefined(typeof(ObsoleteAttribute), false))
150151
continue;
151152

152153
missingTypes.Add(type);
153154
}
154155
}
155-
156156
return missingTypes;
157157
}
158158

@@ -163,13 +163,14 @@ static List<Type> GetTypesMissingFromDefaultProfile(VolumeProfile profile)
163163
/// <param name="profile">VolumeProfile to use.</param>
164164
/// <param name="defaultValueSource">An optional VolumeProfile asset containing default values to use for
165165
/// any components that are added to <see cref="profile"/>.</param>
166-
public static void EnsureAllOverridesForDefaultProfile(VolumeProfile profile, VolumeProfile defaultValueSource = null)
166+
public static void EnsureAllOverridesForDefaultProfile(VolumeProfile profile, VolumeProfile defaultValueSource = null) => TryEnsureAllOverridesForDefaultProfile(profile, defaultValueSource);
167+
internal static bool TryEnsureAllOverridesForDefaultProfile(VolumeProfile profile, VolumeProfile defaultValueSource = null)
167168
{
168169
// It's possible that the volume profile is assigned to the default asset inside the HDRP package. In
169170
// this case it cannot be modified. User is expected to use HDRP Wizard "Fix" to create a local profile.
170171
var path = AssetDatabase.GetAssetPath(profile);
171172
if (CoreEditorUtils.IsAssetInReadOnlyPackage(path))
172-
return;
173+
return false;
173174

174175
bool changed = false;
175176
int numComponentsBefore = profile.components.Count;
@@ -241,6 +242,8 @@ public static void EnsureAllOverridesForDefaultProfile(VolumeProfile profile, Vo
241242
VolumeManager.instance.OnVolumeProfileChanged(profile);
242243
EditorUtility.SetDirty(profile);
243244
}
245+
246+
return changed;
244247
}
245248

246249
/// <summary>
@@ -297,12 +300,14 @@ public static void AddVolumeProfileContextMenuItems(
297300

298301
menu.AddItem(Styles.collapseAll, false, () =>
299302
{
300-
SetComponentEditorsExpanded(componentEditors, false);
303+
if (componentEditors != null)
304+
SetComponentEditorsExpanded(componentEditors, false);
301305
onComponentEditorsExpandedCollapsed?.Invoke();
302306
});
303307
menu.AddItem(Styles.expandAll, false, () =>
304308
{
305-
SetComponentEditorsExpanded(componentEditors, true);
309+
if (componentEditors != null)
310+
SetComponentEditorsExpanded(componentEditors, true);
306311
onComponentEditorsExpandedCollapsed?.Invoke();
307312
});
308313
}

Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public VolumeComponentMenu(string menu)
4545
/// This attribute allows you to add commands to the <b>Add Override</b> popup menu on Volumes,
4646
/// while also specifying the render pipeline(s) for which the command will be supported.
4747
/// </summary>
48-
[Obsolete(@"VolumeComponentMenuForRenderPipelineAttribute is deprecated. Use VolumeComponentMenu with SupportedOnRenderPipeline instead. #from(2023.1)")]
48+
[Obsolete(@"VolumeComponentMenuForRenderPipelineAttribute is deprecated. Use VolumeComponentMenu with SupportedOnRenderPipeline instead. #from(2023.1)", true)]
4949
public class VolumeComponentMenuForRenderPipeline : VolumeComponentMenu
5050
{
5151
/// <summary>
@@ -126,7 +126,7 @@ public sealed class VolumeComponentDeprecated : Attribute
126126
/// <para>
127127
/// In the example above, the custom component `ExampleComponent` extends `VolumeComponent` and defines a parameter
128128
/// (`intensity`) that can be manipulated within the volume framework. The `ClampedFloatParameter` is a type of
129-
/// <see cref="VolumeParameter{T}"/> that ensures the value remains within a specified range.
129+
/// <see cref="VolumeParameter{T}"/> that ensures the value remains within a specified range.
130130
/// </para>
131131
/// </example>
132132
[Serializable]
@@ -164,7 +164,7 @@ public Indent(int relativeAmount = 1)
164164
/// The backing storage of <see cref="parameters"/>. Use this for performance-critical work.
165165
/// </summary>
166166
internal VolumeParameter[] parameterList;
167-
167+
168168
ReadOnlyCollection<VolumeParameter> m_ParameterReadOnlyCollection;
169169

170170
/// <summary>
@@ -355,7 +355,7 @@ public bool AnyPropertiesIsOverridden()
355355
{
356356
for (int i = 0; i < parameterList.Length; ++i)
357357
{
358-
if (parameterList[i].overrideState)
358+
if (parameterList[i].overrideState)
359359
return true;
360360
}
361361
return false;

0 commit comments

Comments
 (0)