/// <summary> /// Helper method to automatically invoke an event /// call if the value has changed. /// </summary> /// <typeparam name="TSender"></typeparam> /// <typeparam name="TArgs"></typeparam> /// <param name="eventDelegate"></param> /// <param name="valid">Whether or not the event should be invoked.</param> /// <param name="sender">The sender instance.</param> /// <param name="reference">A reference to be updated with the new value if valid.</param> /// <param name="value">The value to set the reference if valid.</param> public static Boolean InvokeIf <TSender, TArgs>( this OnEventDelegate <TSender, TArgs> eventDelegate, Boolean valid, TSender sender, ref TArgs reference, TArgs value) { if (valid) { reference = value; eventDelegate?.Invoke(sender, reference); return(true); } return(false); }
public void Show() { // If instant, just set active if (InstantShow) { gameObject.SetActive(true); } else // Otherwise we transition { Tween(PositionToShowAt.y, () => OnShowing?.Invoke()); } hiding = false; if (GetComponentInChildren <Button>() is Button button) { button.interactable = true; } }
public void Hide() { // If instance, just disable if (InstantHide) { gameObject.SetActive(false); } else // Otherwise transition { Tween(PostionToHideAt.y, () => OnHidden?.Invoke()); } hiding = true; if (GetComponentInChildren <Button>() is Button button) { button.interactable = false; } }
public void Handle(Event evt) { mDelegate?.Invoke((T)(evt.Value)); }