// Update is called once per frame void Update() { if (Physics.Linecast(c.transform.position, p.transform.position, out hit)) { if (hit.collider.gameObject.CompareTag("TransBehind")) { MonoBehaviour[] scripts = hit.collider.gameObject.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour s in scripts) { if (s is IFadable) { IFadable fadable = (IFadable)s; fadable.FadeOut(); } } } if (prevHit != null) { if (hit.collider.gameObject != prevHit && prevHit.CompareTag("TransBehind")) { MonoBehaviour[] scripts = prevHit.GetComponents <MonoBehaviour>(); foreach (MonoBehaviour s in scripts) { if (s is IFadable) { IFadable fadable = (IFadable)s; fadable.FadeIn(); } } } } prevHit = hit.collider.gameObject; } }
public eEventTriggerReturn Trigger(StateMachineComponent stateMachine) { IFadable target = _target.GetComponent(); if (target != null) { if (_active) { target.FadeIn(_fadeTime); } else { target.FadeOut(_fadeTime); } } return(eEventTriggerReturn.EventFinished); }
private void Awake() { _fadable = GetComponent <IFadable>(); }