Beispiel #1
0
 protected void TryStartUpdateCoroutine()
 {
     if (_updateCoroutine == null)
     {
         _updateCoroutine = this.CreateCoroutine(UpdateVisibility());
     }
 }
Beispiel #2
0
 public void StartAnimation()
 {
     _animation             = new ECoroutine(Animation(), this);
     _animation.OnFinished += cancelled => {
         graphicContainer.anchoredPosition = Vector2.left * (graphic.rect.width / 2);
     };
 }
Beispiel #3
0
 private void OnVariableChanged(TVariableType newValue)
 {
     if (_updateCoroutine == null)
     {
         _updateCoroutine = this.CreateCoroutine(UpdateVisibility());
     }
 }
Beispiel #4
0
        protected IEnumerator UpdateVisibility()
        {
            yield return(EWait.ForEndOfFrame);

            UpdateText();

            _updateCoroutine = null;
        }
Beispiel #5
0
        public void Tween(TProperty value, UIAnimationDirection animationDirection = UIAnimationDirection.From,
                          Action callback = null, UIAnimationOptions animationOptions = null)
        {
            if (animationOptions == null)
            {
                animationOptions = new UIAnimationOptions();
            }

            if (tweenerCoroutine != null && tweenerCoroutine.Running)
            {
                StopTween();
                tweenerCoroutine.OnFinished += b => {
                    Tween(value, animationDirection, callback, animationOptions);
                };
                return;
            }

            if (animationDirection == UIAnimationDirection.RelativeTo || animationDirection == UIAnimationDirection.RelativeFrom)
            {
                value = AddValues(value, TargetValue);
            }

            if (animationDirection == UIAnimationDirection.To || animationDirection == UIAnimationDirection.RelativeTo)
            {
                TargetValue = value;
            }
            else
            {
                TargetValue  = CurrentValue;
                CurrentValue = value;
            }

            if (animationOptions.SavePosition)
            {
                SavedValue = TargetValue;
            }

            if (animationOptions.Instant)
            {
                CurrentValue = TargetValue;
                return;
            }

            Tweening = true;

            tweenerCoroutine             = _owner.CreateCoroutine(TweenCoroutine(animationOptions.Ease, animationOptions.Duration, animationOptions.Delay));
            tweenerCoroutine.OnFinished += stopped => {
                if (!stopped)
                {
                    CurrentValue = TargetValue;
                }

                Tweening = false;

                callback?.Invoke();
            };
        }
Beispiel #6
0
        private static void InitializePools()
        {
            var pools = Resources.FindObjectsOfTypeAll <ObjectPool>();

            if (pools.Length == 0)
            {
                return;
            }

            var poolsContainer = new GameObject("Pools");

            DontDestroyOnLoad(poolsContainer);

            var executor = poolsContainer.AddComponent <EmptyBehavior>();

            ECoroutine e = new ECoroutine(InitializePoolsCoroutine(poolsContainer, pools), executor);
        }
Beispiel #7
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (_tapIndicator != null)
            {
                return; // can't have two
            }

            if (_selectableComponent && !_selectableComponent.interactable)
            {
                return;
            }

            if (eventData.button != PointerEventData.InputButton.Left || Input.touchCount > 1)
            {
                return;
            }

            if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(transform as RectTransform, eventData.position,
                                                                         overrideCamera,
                                                                         out var localPosition))
            {
                return;
            }

            if (_pointerUpAnimation != null && _pointerUpAnimation.Running)
            {
                _pointerUpAnimation.Stop();
                _pointerUpAnimation = null;
            }

            _tapIndicator = tapIndicatorPool.Spawn(transform, true) as UITapIndicator;

            if (_tapIndicator == null)
            {
                Debug.LogError("Invalid tap indicator prefab", tapIndicatorPool);
                return;
            }

            _tapIndicator.graphic.transform.localPosition = localPosition;

            _pointerDownAnimation = this.CreateCoroutine(_tapIndicator.OnPointerDownAnimation());
        }
Beispiel #8
0
        public void OnPointerUp(PointerEventData eventData)
        {
            if (!_tapIndicator || (_pointerUpAnimation != null && _pointerUpAnimation.Running))
            {
                return; // can't animate if it didn't spawn for some reason
            }

            if (_pointerDownAnimation != null && _pointerDownAnimation.Running)
            {
                _pointerDownAnimation.Stop();
                _pointerDownAnimation = null;
            }

            _pointerUpAnimation = this.CreateCoroutine(_tapIndicator.OnPointerUpAnimation());

            _pointerUpAnimation.OnFinished += stopped => {
                tapIndicatorPool.Return(_tapIndicator);
                _tapIndicator = null;
            };
        }