namespace UIWidgets { using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using UIWidgets.Styles; using UnityEngine; using UnityEngine.UI; /// /// Base generic class for the custom notifications. /// /// Notification type. public abstract class NotificationCustom : NotificationBase, IStylable, IUpgradeable, IHideable where TNotification : NotificationCustom { [SerializeField] Button hideButton; /// /// Gets or sets the button that close current notification. /// /// The hide button. public Button HideButton { get { return hideButton; } set { if (hideButton != null) { hideButton.onClick.RemoveListener(Hide); } hideButton = value; if (hideButton != null) { hideButton.onClick.AddListener(Hide); } } } [SerializeField] [HideInInspector] [Obsolete("Replaced with NotifyInfo component.")] Text text; /// /// Gets or sets the text component. /// /// The text. [HideInInspector] [Obsolete("Replaced with NotifyInfo component.")] public Text Text { get { return text; } set { text = value; } } /// /// Hide delay. /// [SerializeField] public float HideDelay = 10f; static Templates templates; /// /// Notifications templates. /// public static Templates Templates { get { if (templates == null) { templates = new Templates(AddCloseCallback); } return templates; } set { templates = value; } } /// /// Function used to run show animation. /// public Func ShowAnimation; /// /// Function used to run hide animation. /// public Func HideAnimation; Func oldShowAnimation; Func oldHideAnimation; Vector2 oldSize; Quaternion oldRotation; IEnumerator showCoroutine; IEnumerator hideCoroutine; /// /// Start slide up animations after hide current notification. Turn it off if its managed with HideAnimation. /// public bool SlideUpOnHide = true; [SerializeField] NotifyInfoBase notifyInfo; /// /// Gets the notification info. /// /// The notification info. public NotifyInfoBase NotifyInfo { get { if (notifyInfo == null) { notifyInfo = GetComponent(); } return notifyInfo; } } #region buttons /// /// Button instance. /// public class ButtonInstance : DialogButtonCustom { /// /// Initializes a new instance of the class. /// /// Owner. /// Index. /// Info. /// Template. /// Button container. public ButtonInstance(TNotification owner, int index, NotificationButton info, Button template, RectTransform container) : base(owner, index, info, template, container) { } } /// /// Class for the buttons instances. /// protected class ButtonsPool : DialogButtonsPoolCustom { /// /// Initializes a new instance of the class. /// /// Dialog. /// Templates. /// Container. /// List for the active buttons. /// List for the cached buttons. public ButtonsPool(TNotification owner, ReadOnlyCollection