# 3. Target Sorting Layers Part of [[2D Lighting in URP]]. Prev: [[2. Light 2D Types]]. Next: [[4. Shadow Caster 2D and Composite]]. When artists say **light layers** in 2D URP, they usually mean **Target sorting layers** on the Light 2D component: which **sorting layers** (the same layers `SpriteRenderer` / Tilemap use) this light affects. That is **not** 3D URP **Rendering Layers** (the bitmask on MeshRenderers / lights in a Forward+ / 3D URP project). Do not set a 3D rendering layer and expect a sprite to ignore a Light 2D. ## 3.1 Inspector workflow (required) On each Light 2D, open **Target sorting layers** and include only the layers this light should hit. Examples: | Light | Targets | Why | |---|---|---| | Global fill | Default, Ground, Characters | Everyone gets a base exposure | | Window spill | Default, Ground | Does not wash out the UI layer or a "spirit" layer | | Player lantern | Characters, Ground, Default | Follows the hero; maybe skips a far-background layer | | UI / HUD | *(no 2D light, or a dedicated layer you never target)* | Screen-space UI is usually unlit / UI Toolkit ([[UI Toolkit and Diegetic UI]]) | Sorting layers themselves are created in **Tags and Layers** (or the 2D sorting layer list in project settings - use the same list your sprites already use from [[Tilemaps and Tilesets]]). ## 3.2 Scripting Target sorting layers This series **does not** document a public API to set Target sorting layers at runtime. I did not find a documented, stable public setter to recommend on `Light2D` for 6000.5, and **you will not use reflection** to poke serialized fields. If a light must change which layers it hits at runtime, the supported approach here is: - **Enable / disable** whole Light 2D objects (a "spirit-world" light on a Spirit layer, a "real-world" light on Default), or - Keep layers fixed and change **color / intensity**, or - Recheck the URP `Light2D` scripting API in *your* package version; if a public property exists, use that - and only that. Do not ship a "utility" that walks `SerializedObject` or private fields from gameplay code. ## 3.3 Exercise Two sprites on different sorting layers (Background, Characters). A Spot targeted at Characters only should leave the background at the Global fill. If both brighten, the Target sorting layers list still includes Background. ## Sources - Light 2D component reference (6000.5) - Target sorting layers: https://docs.unity.com/en-us/engine/6000.5/manual/2drenderer-light-2d