Skip to content

Commit 1820b10

Browse files
ApoorvaJEvergreen
authored andcommitted
Disable the culling mask setting when only Forward+ is active
This PR makes it a bit more obvious in UI and tooltips that the light culling mask doesn't work in Forward+. If all active renderers are Forward+, then the culling mask setting in the light inspector is greyed out with the following tooltip: ![image](https://media.github.cds.internal.unity3d.com/user/2726/files/5ae12d18-0cc9-494f-abe1-12c419b61909) If even one of the active renderers is something other than Forward+, then the setting is enabled again. But the tooltip also mentions that Forward+ doesn't support the setting: ![image](https://media.github.cds.internal.unity3d.com/user/2726/files/c799444c-c9d4-4814-be48-f987bafe466e)
1 parent ef31d07 commit 1820b10

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,28 @@ static void DrawEmissionContent(UniversalRenderPipelineSerializedLight serialize
279279
static void DrawRenderingContent(UniversalRenderPipelineSerializedLight serializedLight, Editor owner)
280280
{
281281
serializedLight.settings.DrawRenderMode();
282-
EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, Styles.CullingMask);
282+
var rendererList = UniversalRenderPipeline.asset.rendererDataList;
283+
bool hasNonForwardPlusRenderer = false;
284+
foreach (var r in rendererList)
285+
{
286+
if (r is UniversalRendererData ur)
287+
{
288+
if (ur.renderingMode != RenderingMode.ForwardPlus)
289+
{
290+
hasNonForwardPlusRenderer = true;
291+
break;
292+
}
293+
}
294+
else
295+
{
296+
hasNonForwardPlusRenderer = true;
297+
break;
298+
}
299+
}
300+
301+
GUI.enabled = hasNonForwardPlusRenderer;
302+
EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, hasNonForwardPlusRenderer ? Styles.CullingMask : Styles.CullingMaskDisabled);
303+
GUI.enabled = true;
283304
}
284305

285306
static void DrawShadowsContent(UniversalRenderPipelineSerializedLight serializedLight, Editor owner)

Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ private static class Styles
2121
public static readonly GUIContent BakingWarning = EditorGUIUtility.TrTextContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
2222
public static readonly GUIContent DisabledLightWarning = EditorGUIUtility.TrTextContent("Lighting has been disabled in at least one Scene view. Any changes applied to lights in the Scene will not be updated in these views until Lighting has been enabled again.");
2323
public static readonly GUIContent SunSourceWarning = EditorGUIUtility.TrTextContent("This light is set as the current Sun Source, which requires a directional light. Go to the Lighting Window's Environment settings to edit the Sun Source.");
24-
public static readonly GUIContent CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "Specifies which layers will be affected or excluded from the light's effect on objects in the scene. This only applies to objects rendered using the Forward rendering path, and transparent objects rendered using the Deferred rendering path.");
24+
public static readonly GUIContent CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "Specifies which layers will be affected or excluded from the light's effect on objects in the scene. This only applies to objects rendered using the Forward rendering path, and transparent objects rendered using the Deferred rendering path. This setting is ignored in the Forward+ rendering path.");
25+
public static readonly GUIContent CullingMaskDisabled = EditorGUIUtility.TrTextContent("Culling Mask", "Culling Mask is disabled. This is because all active renderers use the Forward+ rendering path, which doesn't support Culling Mask. To enable this setting, change the rendering path to Forward or Deferred in the active Universal Render Pipeline Asset.");
2526

2627
public static readonly GUIContent ShadowRealtimeSettings = EditorGUIUtility.TrTextContent("Realtime Shadows", "Settings for realtime direct shadows.");
2728
public static readonly GUIContent ShadowStrength = EditorGUIUtility.TrTextContent("Strength", "Controls how dark the shadows cast by the light will be.");

0 commit comments

Comments
 (0)