Exemplo n.º 1
0
    //parameters: float width, float duration, MMTweeningEaseEnum ease
    protected override void StartTransition(bool isActivate, object[] parameters)
    {
        if (_activeTween != null)
        {
            UIVirtualValueTweenController.Instance.StopTweener(_activeTween);

            _activeTween = null;
        }

        _isActive = isActivate;

        if (!_isActive)
        {
            HideContent();
        }

        float width             = (float)parameters[0];
        float duration          = (float)parameters[1];
        UITweeningEaseEnum ease = (UITweeningEaseEnum)parameters[2];

        UIVirtualValueTweenerInfo tweenInfo = new UIVirtualValueTweenerInfo()
        {
            Duration        = duration,
            Ease            = ease,
            From            = RectTransform.sizeDelta.x,
            IgnoreTimeScale = true,
            To       = GetNewVertSize(width),
            Callback = OnTweenUpdated
        };

        UIVirtualValueTweener newTween = new UIVirtualValueTweener(tweenInfo);

        UIVirtualValueTweenController.Instance.StartTweener(newTween);
    }
Exemplo n.º 2
0
    private void ChangePage(int selectedPage)
    {
        _activePage = selectedPage;

        if (ActivateUIOcclusion)
        {
            BehaviourList.ForEach(b => b.ResetUI(false));
        }

        if (ActivateUIOcclusion)
        {
            ActivatePageWithAdjacents();
        }

        StopTweensIfActive();

        UIVirtualValueTweenerInfo pageTweenInfo = new UIVirtualValueTweenerInfo()
        {
            Callback        = PageTweenUpdate,
            Duration        = TransitionDuration,
            Ease            = UITweeningEaseEnum.InOutCubic,
            From            = PageScrollrect.horizontalNormalizedPosition,
            To              = _headerSlideAmountPerPage * (_activePage - 1),
            IgnoreTimeScale = true
        };

        _pageTweener = new UIVirtualValueTweener(pageTweenInfo);

        UIVirtualValueTweenController.Instance.StartTweener(_pageTweener);
    }
Exemplo n.º 3
0
    private void Init()
    {
        _pageTweener = null;

        _isDirty = false;

        PageButtonsHorLayoutGroup.SetLayoutHorizontal();
        Canvas.ForceUpdateCanvases();

        _headerWidth = HeaderSlider.GetComponent <RectTransform>().rect.width;

        var buttonRect = PageButtons[0].GetComponent <RectTransform>().rect;

        HandleIndicator.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, buttonRect.height);
        HandleIndicator.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, buttonRect.width);

        _totalTransitionCountBTPages = PageButtons.Count - 1;
        _headerSlideAmountPerPage    = 1f / _totalTransitionCountBTPages;

        PageScrollrect.horizontal = true;

        PageScrollrect.onValueChanged.AddListener(OnScrollViewDragged);

        if (ActivateUIOcclusion)
        {
            BehaviourList.ForEach(b => b.ResetUI(false));
        }

        PageButtons.ForEach(b => b.OnButtonPressedDown += OnPageButtonPressed);

        float slideAreaWidth = _headerWidth - buttonRect.width;

        HandleSlideArea.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, slideAreaWidth);
    }
Exemplo n.º 4
0
 private void StopTweensIfActive()
 {
     if (_pageTweener != null)
     {
         UIVirtualValueTweenController.Instance.StopTweener(_pageTweener);
         _pageTweener = null;
     }
 }
Exemplo n.º 5
0
    private void PageTweenUpdate(float value, bool isFinished)
    {
        SetSliderValues(value);

        if (isFinished)
        {
            _pageTweener = null;
        }
    }
Exemplo n.º 6
0
    //parameters: float width
    public override void ResetUI(bool isActivate, params object[] parameters)
    {
        if (_activeTween != null)
        {
            UIVirtualValueTweenController.Instance.StopTweener(_activeTween);

            _activeTween = null;
        }

        _isActive = isActivate;

        RectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, GetNewVertSize((float)parameters[0]));

        if (_isActive)
        {
            ShowContent();
        }
        else
        {
            HideContent();
        }
    }
Exemplo n.º 7
0
    private void StartFloatTransition(float duration, UITweeningEaseEnum ease, float to, Vector2 pivot)
    {
        if (_activeTween != null)
        {
            UIVirtualValueTweenController.Instance.StopTweener(_activeTween);

            _activeTween = null;
        }

        RectTransform.SetPivotWithCounterAdjustPosition(pivot, InitialSize);

        UIVirtualValueTweenerInfo newTweenInfo = new UIVirtualValueTweenerInfo()
        {
            Callback        = OnFloatTweenUpdated,
            Duration        = duration,
            Ease            = ease,
            IgnoreTimeScale = true,
            From            = RectTransform.sizeDelta.y,
            To = GetNewVertSize(to)
        };

        _activeTween = new UIVirtualValueTweener(newTweenInfo);
        UIVirtualValueTweenController.Instance.StartTweener(_activeTween);
    }
Exemplo n.º 8
0
        private static void SetTweener(ScrollRect targetScrollRect, float deltaAmount, Action <float> callback)
        {
            targetScrollRect.enabled = false;

            Action <float, bool> onTweenerUpdate = delegate(float value, bool isFinished)
            {
                if (isFinished)
                {
                    if (callback != null)
                    {
                        callback(deltaAmount);
                    }

                    targetScrollRect.enabled = true;
                }

                Vector3 curPos = targetScrollRect.content.position;
                curPos.y = value;

                targetScrollRect.content.position = curPos;
            };

            UIVirtualValueTweenerInfo tweenerInfo = new UIVirtualValueTweenerInfo
            {
                Callback        = onTweenerUpdate,
                Duration        = 0.5f,
                Ease            = UITweeningEaseEnum.OutCubic,
                From            = targetScrollRect.content.position.y,
                To              = targetScrollRect.content.position.y + deltaAmount,
                IgnoreTimeScale = true
            };

            UIVirtualValueTweener newTweener = new UIVirtualValueTweener(tweenerInfo);

            UIVirtualValueTweenController.Instance.StartTweener(newTweener);
        }