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); }
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); }
protected override void Awake() { base.Awake(); _floatingButtonQueue = new Queue <UIFloatingButtonBehaviour>(); BehaviourList.ForEach(b => b.ResetUI(false)); }
public override void OnSubContainerPressDown(UIHorizontalAccordionBehaviour interactedContainer, PointerEventData eventData) { float expandedHeight = 1 - (MinSize * (BehaviourList.Count - 1)); interactedContainer.Activate(expandedHeight, Duration, Ease); BehaviourList.FindAll(b => b != interactedContainer).ForEach(b => b.Deactivate(MinSize, Duration, Ease)); base.OnSubContainerPressDown(interactedContainer, eventData); }
public void SetBehaviours(BehaviourList behaviours, string label = "") { _label = label; _behaviours = behaviours; foreach (IBehaviour behaviour in _behaviours) { behaviour.start(new BehaviourContext(_position, _velocity, _settings)); } }
protected override void Awake() { base.Awake(); if (DefaultOpenedPage >= BehaviourList.Count) { DefaultOpenedPage = 0; } BehaviourList.ForEach(b => b.ResetUI(false, MinSize)); BehaviourList[DefaultOpenedPage].ResetUI(true, 1 - (MinSize * (BehaviourList.Count - 1))); }
private void OnScrollViewDragged(Vector2 deltaDir) { if (!_isCompsDisabled) { DisableNonUsedComps(); } if (Scrollrect.velocity.x < 0) { for (int i = 0; i < BehaviourList.Count; i++) { if (Scrollrect.transform.InverseTransformPoint(BehaviourList[i].gameObject.transform.position).x < _bottomDisablePoint - _offset) { var lastChildOnHier = BehaviourList.Find(b => b.RectTransform == Scrollrect.content.GetChild(Scrollrect.content.childCount - 1)); var newPos = lastChildOnHier.RectTransform.anchoredPosition; newPos.x += (lastChildOnHier.RectTransform.rect.width / 2f) + (BehaviourList[i].RectTransform.rect.width / 2f) + HorLayoutGroup.spacing; BehaviourList[i].RectTransform.anchoredPosition = newPos; BehaviourList[i].RectTransform.SetAsLastSibling(); } } } else { for (int i = BehaviourList.Count - 1; i >= 0; i--) { if (Scrollrect.transform.InverseTransformPoint(BehaviourList[i].gameObject.transform.position).x > _topDisablePoint + _offset + 120f) { var firstChildOnHier = BehaviourList.Find(b => b.RectTransform == Scrollrect.content.GetChild(0)); var newPos = firstChildOnHier.RectTransform.anchoredPosition; newPos.x -= (firstChildOnHier.RectTransform.rect.width / 2f) + (BehaviourList[i].RectTransform.rect.width / 2f) + HorLayoutGroup.spacing; BehaviourList[i].RectTransform.anchoredPosition = newPos; BehaviourList[i].RectTransform.SetAsFirstSibling(); } } } }
public override void OnSubContainerDragBegin(UIHorizontalCarouselBehaviour interactedContainer, PointerEventData eventData) { interactedContainer.transform.SetAsLastSibling(); UIHorizontalCarouselBehaviour nextBehavContainer = GetNextBehavContainer(eventData, BehaviourList.IndexOf(interactedContainer)); nextBehavContainer.transform.SetAsLastSibling(); if (Transition != CarouselTransitionEnum.Instant) { interactedContainer.Deactivate(Transition, Duration, Ease, MinSize, GetPivotForContainer(eventData, false)); float expandedWidth = 1 - MinSize; nextBehavContainer.Activate(Transition, Duration, Ease, expandedWidth, GetPivotForContainer(eventData, true)); } else { interactedContainer.Deactivate(Transition, MinSize); nextBehavContainer.Activate(Transition, 1 - MinSize); } base.OnSubContainerDragBegin(interactedContainer, eventData); }