Skip to content

Commit

Permalink
Disable the culling mask setting when only Forward+ is active
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
ApoorvaJ authored and Evergreen committed Feb 8, 2024
1 parent ef31d07 commit 1820b10
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,28 @@ static void DrawEmissionContent(UniversalRenderPipelineSerializedLight serialize
static void DrawRenderingContent(UniversalRenderPipelineSerializedLight serializedLight, Editor owner)
{
serializedLight.settings.DrawRenderMode();
EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, Styles.CullingMask);
var rendererList = UniversalRenderPipeline.asset.rendererDataList;
bool hasNonForwardPlusRenderer = false;
foreach (var r in rendererList)
{
if (r is UniversalRendererData ur)
{
if (ur.renderingMode != RenderingMode.ForwardPlus)
{
hasNonForwardPlusRenderer = true;
break;
}
}
else
{
hasNonForwardPlusRenderer = true;
break;
}
}

GUI.enabled = hasNonForwardPlusRenderer;
EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, hasNonForwardPlusRenderer ? Styles.CullingMask : Styles.CullingMaskDisabled);
GUI.enabled = true;
}

static void DrawShadowsContent(UniversalRenderPipelineSerializedLight serializedLight, Editor owner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private static class Styles
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.");
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.");
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.");
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.");
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.");
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.");

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

0 comments on commit 1820b10

Please sign in to comment.