protected void TryStartUpdateCoroutine() { if (_updateCoroutine == null) { _updateCoroutine = this.CreateCoroutine(UpdateVisibility()); } }
public void StartAnimation() { _animation = new ECoroutine(Animation(), this); _animation.OnFinished += cancelled => { graphicContainer.anchoredPosition = Vector2.left * (graphic.rect.width / 2); }; }
private void OnVariableChanged(TVariableType newValue) { if (_updateCoroutine == null) { _updateCoroutine = this.CreateCoroutine(UpdateVisibility()); } }
protected IEnumerator UpdateVisibility() { yield return(EWait.ForEndOfFrame); UpdateText(); _updateCoroutine = null; }
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(); }; }
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); }
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()); }
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; }; }