コード例 #1
0
        /// <summary>
        /// Setups the button with the specified button data.
        /// </summary>
        /// <param name="data">The button data.</param>
        public override void Setup(ButtonData data)
        {
            base.Setup(data);

            if (lastCooldowned != null)
            {
                lastCooldowned.Timer.OnTick   -= OnCooldownTickHandler;
                lastCooldowned.Timer.OnFinish -= OnFinishHandler;
                lastCooldowned = null;
            }

            if (data is ButtonDataCooldowned cooldownedData)
            {
                lastCooldowned = cooldownedData.Cooldowned;
                lastCooldowned.Timer.OnTick   += OnCooldownTickHandler;
                lastCooldowned.Timer.OnFinish += OnFinishHandler;

                if (lastCooldowned.Timer.IsTicking)
                {
                    ActivateButton(false);
                }
            }

            ClearCooldownText();
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ButtonDataCooldowned"/> class.
 /// </summary>
 /// <param name="cooldowned">The cooldowned object.</param>
 /// <param name="onClickAction">The on button click callback.</param>
 /// <param name="indexButton">The button index.</param>
 /// <param name="text">The button text.</param>
 /// <param name="popupDescription">The popup description.</param>
 /// <param name="isActive">if set to <c>true</c> button is interactable.</param>
 /// <param name="isFlashing">if set to <c>true</c> button is flashing.</param>
 /// <param name="hotKey">The button hotkey.</param>
 public ButtonDataCooldowned(ICooldowned cooldowned, UnityAction <int> onClickAction, int indexButton, string text,
                             string popupDescription, bool isActive, bool isFlashing = false, KeyCode?hotKey = null)
     : base(onClickAction, indexButton, text, popupDescription, isActive, isFlashing, hotKey)
 {
     Cooldowned = cooldowned;
 }