public void Reposition() { if (mStarted) { Transform transform = base.transform; mChildren.Clear(); List <Transform> children = this.children; if (children.Count > 0) { RepositionVariableSize(children); } if (mDrag != null) { mDrag.UpdateScrollbars(recalculateBounds: true); mDrag.RestrictWithinBounds(instant: true); } else if (mPanel != null) { mPanel.ConstrainTargetToBounds(transform, immediate: true); } if (onReposition != null) { onReposition(); } } else { repositionNow = true; } }
/// <summary> /// Recalculate the position of all elements within the table, sorting them alphabetically if necessary. /// </summary> public void Reposition() { if (mStarted) { Transform myTrans = transform; mChildren.Clear(); List <Transform> ch = children; if (ch.Count > 0) { RepositionVariableSize(ch); } if (mDrag != null) { mDrag.UpdateScrollbars(true); mDrag.RestrictWithinBounds(true); } else if (mPanel != null) { mPanel.ConstrainTargetToBounds(myTrans, true); } if (onReposition != null) { onReposition(); } } else { repositionNow = true; } }
public void Reposition() { if (mStarted) { var target = transform; mChildren.Clear(); var children = this.children; if (children.Count > 0) { RepositionVariableSize(children); } if (mDrag != null) { mDrag.UpdateScrollbars(true); mDrag.RestrictWithinBounds(true); } else if (mPanel != null) { mPanel.ConstrainTargetToBounds(target, true); } onReposition?.Invoke(); } else { repositionNow = true; } }
void OnSpringFinished() { //完成拖拽滑动操作后的事件 m_panel.RestrictWithinBounds(false); m_panel.gameObject.GetComponent <SpringPanel>().onFinished = null; if (OnChangeFinished != null) { OnChangeFinished(m_uiConnector.Current.Item); } }
void OnTabSelection(int selectIndex) { if (_currentSlectedIndex == selectIndex) { return; } _currentSlectedIndex = selectIndex; HideAllItems(); float currentTime = Time.realtimeSinceStartup; float deltaTime = currentTime - _lastGetListTime; if (deltaTime > 60) { NetworkManager.Instance.StoreGetList(OnStoreGetListHandler); _lastGetListTime = currentTime; } else { List <FCUIStoreItem> items = new List <FCUIStoreItem>(); switch (selectIndex) { case 0: //store item sell. if (null != _goodsOnSellDataList) { foreach (FC_StoreData storeData in _goodsOnSellDataList) { items.Add(MakeFCUIStoreItem(storeData)); } SortAndRename(items); } break; case 1: for (int i = 0; i < 6; ++i) { items.Add(MakeFCUIStoreItem(i)); } grid.repositionNow = true; uiDraggablePanel.RestrictWithinBounds(false); break; case 2: if (null != _storeSCExchangeDataList) { foreach (StoreSCExchangeData storeSCExchangeData in _storeSCExchangeDataList) { items.Add(MakeFCUIStoreItem(storeSCExchangeData)); } SortAndRename(items); } break; } } }
void UpdateLimits(bool reposition) { screenCenter = new Vector2(Screen.width / 2, Screen.height / 2); Vector4 clip = myPanel.clipRange; if (Screen.width >= Screen.height) { clip.z = Screen.width * 768f / Screen.height; clip.w = 768f; widthFactor = 768f / Screen.height; } else { clip.z = 768f; clip.w = Screen.height * 768f / Screen.width; widthFactor = 768f / Screen.width; } myPanel.clipRange = clip; if (reposition) { myDragPanel.RestrictWithinBounds(true); } minZoom = 0.5f; float aspectRatio = (float)Screen.width / (float)Screen.height; float referenceAR = 4f / 3f; if (aspectRatio > referenceAR) { minZoom *= aspectRatio / referenceAR; if (currentZoom < minZoom) { SetMapZoomAndPosition(Vector3.zero, minZoom, false); } } }
void OnPanelDrag(Vector2 offset) { if (!bCheck) { return; } if (topCheckTrans == null || bottomCheckTrans == null) { return; } if (offset.y < 0) { float bottomMarkRelatePos = transform.InverseTransformPoint(bottomMarkTrans.position).y; //Debug.LogWarning("bottom pos: " + bottomMarkRelatePos); if (bottomMarkRelatePos > bottomItemOffsetForPanel) { RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().OnClickPrePage(); int index = 10 + RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().addItemCount; if (index == 10) { return; } SetBottomTargetItem(RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().m_gridFoodItemList[index - 1].gameObject); Bounds checkBounds = NGUIMath.CalculateRelativeWidgetBounds(transform, bottomTargetTrans); float targetPos = checkBounds.center.y - checkBounds.extents.y; bCheck = false; dragPanel.MoveRelative(new Vector2(0, bottomItemOffsetForPanel - targetPos)); dragPanel.RestrictWithinBounds(true); bCheck = true; } } else if (offset.y > 0) { float TopMarkRelatePos = transform.InverseTransformPoint(TopMarkTrans.position).y; if (TopMarkRelatePos < topItemOffsetForPanel) { RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().OnClickNextPage(); int index = 6 - RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().addItemCount; //Debug.Log("countttttttttt" + index); if (index == 6) { return; } SetTopTargetItem(RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().m_gridFoodItemList[index - 1].gameObject); Bounds checkBounds = NGUIMath.CalculateRelativeWidgetBounds(transform, topTargetTrans); float targetPos = checkBounds.center.y + checkBounds.extents.y; bCheck = false; dragPanel.MoveRelative(new Vector2(0, topItemOffsetForPanel - targetPos)); dragPanel.RestrictWithinBounds(true); bCheck = true; } } }
public void ConstrainContents() { dragPanel.RestrictWithinBounds(false); }