Skip to content

X-Ray

Enable Xray Enabled or call SetXRay(true). Hidden parts become a silhouette; visible parts render normally with their outline if enabled.

var h = GetComponent<Highlightable>();
h.SetXRay(true);
h.SetXRay(true, new Color(1f, 0.3f, 0.2f, 0.6f));
h.ClearXRayOverrides();

Renderer Feature > X Ray

Setting Default Behavior
Color Blue #3373FF, alpha 0.6 Silhouette color/opacity
Rim Strength 0.35 Edge brightness; 0 gives a flat silhouette
Rim Power 2 Higher makes the rim thinner
Rim Color White Edges shift toward this color; use a lighter team color to preserve identity
Pattern None None, Scanlines, Dots
Pattern Scale 6 Repeat size in pixels at 1080p
Pattern Gap Opacity 0.25 Opacity remaining in gaps
Scanline Speed 0 Repeats/second; sign controls direction; scaled time
Outline Width 0 Hidden-part outline in pixels at 1080p; 0 disables
Occluder Layers Everything Which layers trigger X-Ray; narrowing adds a depth pass
Occlusion Bias 0.05 Minimum distance behind an occluder, in world units; prevents contact flicker

Choose occluders

Create a Foliage layer for objects that should not trigger X-Ray and exclude it from Occluder Layers. The demo uses Ignore Raycast for its bush/crate because packages cannot add project layers.

With a narrowed filter, only opaque/alpha-clipped renderers on selected layers count. Clipped holes and material Render Face are respected. Custom shaders without _Cull are treated as two-sided.

Parts hidden by excluded objects receive no X-Ray and behave like hidden parts of an object without X-Ray.

Everything uses camera depth without an additional filter pass. Narrowing adds one depth pass over selected layers. If the required depth is unavailable, X-Ray is skipped for that camera, and the Inspector/Console report it once.

Camera stacking

Keep highlighted objects and occluders on the same camera. Transparent surfaces without depth writes cannot trigger X-Ray. See Known Limitations.