private void OnEnter(Collider other) { bool isUnityAction = action.CheckUnityEventAction(); bool isCustomUnityEvent = refAction.CheckUnityEvent(); // For actions, handle setting this to inactive in the invoked object in order to do conditionally. if (isUnityAction || isCustomUnityEvent) { if (isUnityAction) { action.Invoke(); } if (isCustomUnityEvent) { refAction.Invoke(other.transform.GetParentRecursive <Transform>()); } } // For entering once. else if (game.ActivateTrigger(Id)) { Debug.Log($"{name} Entered: <{other.gameObject.name}> Setting inactive"); this.gameObject.SetActive(false); } if (isForceHide) { this.gameObject.SetActive(false); } }
public static bool SafeInvoke(this UnityEvent unityEvent) { if (unityEvent.CheckUnityEventAction()) { unityEvent.Invoke(); return(true); } return(false); }
// Called from Level Behavior public void OnSubmitFailure() { Debug.Log($"{name} Reaction to Failure"); EndInput(); bool isUnityAction = failureAction.CheckUnityEventAction(); if (isUnityAction) { failureAction.Invoke(); } }
// Called from Level Behavior public void OnSubmitSuccess() { Debug.Log($"{name} Reaction to Success"); EndInput(); bool isUnityAction = successAction.CheckUnityEventAction(); if (isUnityAction) { successAction.Invoke(); } }
void OnTriggerExit(Collider other) { if (isColliding) { return; } isColliding = true; if (other.tag == Const_Tags.Player) { if (exitAction.CheckUnityEventAction()) { exitAction.Invoke(); } } }
public virtual void TurnOn() { isOn = true; rendererChild.GetComponent <SpriteRenderer>().sprite = onSprite; if (!isStateless) { game.SetSwitchState(switchId, true); } if (!isSFXOverriden) { GetComponent <AudioSource>().PlayOneShot(Script_SFXManager.SFX.SwitchOn, Script_SFXManager.SFX.SwitchOnVol); } if (onAction.CheckUnityEventAction()) { onAction.Invoke(); } Script_InteractableObjectEventsManager.SwitchOn(nameId); }