Custom Hider Behaviors
The built-in Hider Behaviors cover common cases, but it's easy to write your own. Subclass HiderBehavior and implement the OnReveal() and OnHide() methods with your logic.
Minimal Example
using FOW;
using UnityEngine;
public class HiderFadeAlpha : HiderBehavior
{
[SerializeField] CanvasGroup group;
protected override void OnReveal()
{
// called when a revealer sees this hider
group.alpha = 1f;
}
protected override void OnHide()
{
// called when the hider leaves all lines of sight
group.alpha = 0f;
}
}
How It Works
HiderBehaviorrequires a Fog Of War Hider on the same GameObject (enforced with[RequireComponent]).- On
Awake, the base class callsOnHide()once and subscribes to the hider's visibility event — so objects begin in the hidden state. - When visibility changes,
OnReveal()orOnHide()is called accordingly.
Note
If you override Awake in your subclass, call base.Awake() so the subscription is set up.
Detecting Per-Revealer Visibility
A HiderBehavior reacts to the hider's overall state. If you instead need to know which revealer saw the hider (for example, to attribute a sighting to a specific player), subscribe to the revealer's event — see Hider Visibility Events.