VisibilitySwitch
Any entity with VisibilitySwitch component can be revealed or hidden by the fog system depending on whether vision sources cover its check points.
Overview
In the ECS version there are multiple related types:
| Type | Kind | Purpose |
|---|---|---|
VisibilitySwitchAuthoring |
MonoBehaviour |
Placed on a sub-scene GameObject; baked into ECS at build/enter play mode |
DetectionLayer |
IComponentData |
Which fog layer(s) can reveal this entity |
IsVisible |
IComponentData |
Current visibility state (written by CheckVisibilitySystem) |
DynamicBuffer<CheckPoint> |
IBufferElementData |
Local-space sampling positions |
FadePercent |
IComponentData, IEnableableComponent |
Optional smooth fade value (drives _FadePercent shader property) |
VisibilitySwitchAuthoring (Inspector)
Add VisibilitySwitchAuthoring to any GameObject inside a Unity sub-scene that should be revealed or hidden by the fog.
| Property | Type | Default | Description |
|---|---|---|---|
| Layer | VisionLayer |
R |
Which vision layer(s) can reveal this entity (see Vision Layers) |
| Use Center As Checkpoint | bool |
true |
When enabled, uses the entity's center as a single check point |
| Check Points | Vector2[] |
[(0, 0)] |
Array of local XZ offsets for visibility sampling (only visible when "Use Center As Checkpoint" is disabled) |
| Use Fade Transition | bool |
false |
When enabled, the entity fades in/out instead of instantly appearing/disappearing. Requires a material with a specially configured shader (see Entity Fade Setup) |
Check Points
The Check Points array allows you to sample multiple positions on large entities. An entity is treated as visible as soon as any check point falls inside any matching vision source.
When Use Center As Checkpoint is enabled, the system uses a single point at (0, 0) relative to the entity's transform.