예제 #1
0
        /// <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);
        }
예제 #2
0
    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;
        }
    }
예제 #3
0
    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;
        }
    }
예제 #4
0
 public void Handle(Event evt)
 {
     mDelegate?.Invoke((T)(evt.Value));
 }