Exemple #1
0
        public void Open(bool instant = false, bool setInteractable = true)
        {
            if (!m_Ready)
            {
                m_DelayedStatus = true;
                return;
            }

            if (!m_Open)
            {
                dialogOpen.Invoke();
            }

            m_Open = true;

            if (instant || !Application.isPlaying)
            {
                OnOpenTransitionComplete();
            }
            else
            {
                SetInteractable(setInteractable);

                m_OpenDialogTween.startValue  = m_CanvasGroup.alpha;
                m_OpenDialogTween.targetValue = 1f;
                m_TweenRunner.StartTween(m_OpenDialogTween, EaseType.EaseInCubic);
            }
        }
Exemple #2
0
        void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
        {
            // If the slider is close to zero users may not be able to see that it can be dragged, in that case, set
            // it to where they tap the slider
            if (Math.Abs(m_Slider.fillAmount) < 0.01f)
            {
                var pointerPos = eventData.LocalPosition(m_ContainerRect);
                var rect       = m_ContainerRect.rect;
                var factor     = (pointerPos.x + rect.width / 2f) / rect.width;
                if (m_NumberType == NumberType.Float)
                {
                    var value    = Mathf.Lerp(m_MinFloat, m_MaxFloat, factor);
                    var newFloat = ProcessNumber(value);
                    text = newFloat.ToString(m_FloatFieldFormatString);

                    onFloatValueChanged.Invoke(newFloat);
                }
                else
                {
                    var value  = Mathf.Lerp(m_MinInt, m_MaxInt, factor);
                    var newInt = ProcessNumber(Mathf.RoundToInt(value));
                    text = newInt.ToString(k_IntFieldFormatString);

                    onIntValueChanged.Invoke(newInt);
                }
            }

            m_SliderColorTween.startColor  = m_Slider.color;
            m_SliderColorTween.targetColor = UIConfig.propertySelectedColor;
            m_SliderColorTweenRunner.StartTween(m_SliderColorTween, EaseType.EaseOutCubic);
        }
        public static TweenRunner <ColorTween> TweenColor(this MonoBehaviour mb, Material material, Color fromColor,
                                                          Color toColor, float duration, ColorTween.ColorTweenMode colorTweenMode = ColorTween.ColorTweenMode.All,
                                                          EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false, UnityAction onCompleteCallback = null)
        {
            var colorTween = new ColorTween
            {
                startColor      = fromColor,
                targetColor     = toColor,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            colorTween.AddOnChangedCallback(newColor => material.color = newColor);

            if (onCompleteCallback != null)
            {
                colorTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <ColorTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(colorTween, easeType);

            return(tweenRunner);
        }
        public static TweenRunner <RotationTween> TweenLocalRotation(this MonoBehaviour mb, Transform transform, Quaternion toRotation,
                                                                     float duration, EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false,
                                                                     UnityAction onCompleteCallback    = null)
        {
            var rotationTween = new RotationTween
            {
                startRotation   = transform.localRotation,
                targetRotation  = toRotation,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            rotationTween.AddOnChangedCallback(newRotation => transform.localRotation = newRotation);

            if (onCompleteCallback != null)
            {
                rotationTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <RotationTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(rotationTween, easeType);

            return(tweenRunner);
        }
        public static TweenRunner <ScaleTween> TweenScale(this MonoBehaviour mb, Transform transform, Vector3 toScale,
                                                          float duration, EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false,
                                                          UnityAction onCompleteCallback    = null)
        {
            var scaleTween = new ScaleTween
            {
                startScale      = transform.localScale,
                targetScale     = toScale,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            scaleTween.AddOnChangedCallback(newScale => transform.localScale = newScale);

            if (onCompleteCallback != null)
            {
                scaleTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <ScaleTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(scaleTween, easeType);

            return(tweenRunner);
        }
        public static TweenRunner <PositionTween> TweenLocalPosition(this MonoBehaviour mb, Transform transform,
                                                                     Vector3 toPosition,
                                                                     float duration, EaseType easeType = EaseType.Linear, bool ignoreTimeScale = false,
                                                                     UnityAction onCompleteCallback    = null)
        {
            var positionTween = new PositionTween
            {
                startPosition   = mb.transform.position,
                targetPosition  = toPosition,
                duration        = duration,
                ignoreTimeScale = ignoreTimeScale
            };

            positionTween.AddOnChangedCallback(newPosition => transform.localPosition = newPosition);

            if (onCompleteCallback != null)
            {
                positionTween.AddOnCompleteCallback(onCompleteCallback);
            }

            var tweenRunner = new TweenRunner <PositionTween>();

            tweenRunner.Init(mb);
            tweenRunner.StartTween(positionTween, easeType);

            return(tweenRunner);
        }
        public void Fold(bool instant = false)
        {
            if (!m_IsFolded)
            {
                rectFolded.Invoke();
            }

            m_IsFolded = true;

            if (instant || !Application.isPlaying)
            {
                OnFoldTransitionComplete();
            }
            else
            {
                m_FoldTween.startValue  = new Rect(rectTransform.anchoredPosition, rectTransform.sizeDelta);
                m_FoldTween.targetValue = m_FoldedRect;
                m_TweenRunner.StartTween(m_FoldTween, EaseType.EaseInCubic);
            }
        }
Exemple #8
0
        /// <summary>
        /// Set the active tab using the tab index.
        /// </summary>
        /// <param name="tabIndex">The index of the tab to set as active.</param>
        /// <param name="instant">If true, skips animated transition and opens instantly.</param>
        public void SetActiveTab(int tabIndex, bool instant = false)
        {
            if (tabIndex >= m_NestedDialogs.Count)
            {
                Debug.LogError("You are trying to set a tab index for a tab dialog that doesn't exist.",
                               gameObject);
                return;
            }

            m_ActiveTabIndex = tabIndex;
            var tab = m_NestedDialogs[activeTabIndex];

            if (tab == m_ActiveDialog)
            {
                return;
            }

            m_StartXPos = m_DialogContainer.anchoredPosition.x;

            // Prevent interaction on dialog while moving
            foreach (var dialog in m_NestedDialogs)
            {
                dialog.SetInteractable(false);
            }

            // Prevent interaction on dialog while moving
            m_ActiveDialog = tab;
            m_ActiveDialog.Open(true, false);

            if (!instant && Application.isPlaying)
            {
                m_MoveWindowTweenRunner.StartTween(m_MoveWindowTween);
            }
            else
            {
                OnMoveTab(1f);
                OnMoveTransitionComplete();
            }
        }
Exemple #9
0
 void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
 {
     m_SliderColorTween.startColor  = m_Slider.color;
     m_SliderColorTween.targetColor = UIConfig.propertySelectedColor;
     m_SliderColorTweenRunner.StartTween(m_SliderColorTween, EaseType.EaseOutCubic);
 }
Exemple #10
0
 public void StartLooping()
 {
     m_ProgressImage.fillAmount = 0.75f;
     m_TweenRunner.StartTween(m_LoopingTween, EaseType.Linear, true, TweenLoopType.Loop);
 }