public UGUISlider(LayoutScript script) : base("Slider") { mScript = script; mDirection = DRAG_DIRECTION.DD_HORIZONTAL; mMode = SLIDER_MODE.SM_FILL; }
public void autoAdjustParent(ref Vector3 parentPos, ref Vector2 parentSize, Vector2 viewportSize) { if (isClampInner()) { Vector2 windowSize = getWindowSize(); parentSize = windowSize; DRAG_DIRECTION dragDirection = mDragViewComponent.getDragDirection(); if (dragDirection == DRAG_DIRECTION.DD_HORIZONTAL || dragDirection == DRAG_DIRECTION.DD_FREE) { parentSize.x = windowSize.x + (windowSize.x - viewportSize.x) * 2.0f; parentPos.x = -viewportSize.x * 0.5f + parentSize.x * 0.5f; } if (dragDirection == DRAG_DIRECTION.DD_VERTICAL || dragDirection == DRAG_DIRECTION.DD_FREE) { parentSize.y = windowSize.y + (windowSize.y - viewportSize.y) * 2.0f; parentPos.y = -viewportSize.y * 0.5f + parentSize.y * 0.5f; } } else { parentSize = viewportSize; DRAG_DIRECTION dragDirection = mDragViewComponent.getDragDirection(); if (dragDirection == DRAG_DIRECTION.DD_HORIZONTAL || dragDirection == DRAG_DIRECTION.DD_FREE) { parentPos.x = 0.0f; } if (dragDirection == DRAG_DIRECTION.DD_VERTICAL || dragDirection == DRAG_DIRECTION.DD_FREE) { parentPos.y = 0.0f; } } }
public txNGUIDragView() { mType = UI_TYPE.UI_NGUI_DRAG_VIEW; mDragDirection = DRAG_DIRECTION.DD_HORIZONTAL; mMinPos = Vector3.zero; mMaxPos = Vector3.zero; }
public override void resetProperty() { base.resetProperty(); mMutexDragView.Clear(); mDragingCallback = null; mReleaseDragCallback = null; mPositionChangeCallback = null; mOnDragViewStartCallback = null; mWindow = null; mDragDirection = DRAG_DIRECTION.HORIZONTAL; mClampType = CLAMP_TYPE.EDGE_IN_RECT; mMinRelativePos = -Vector3.one; mMaxRelativePos = Vector3.one; mMoveSpeedScale = 1.0f; mAttenuateFactor = 2.0f; mMoveToEdgeSpeed = 5.0f; mDragAngleThreshold = 0.0f; mDragLengthThreshold = 10.0f; mAutoClampSpeed = 10.0f; mClampInner = true; mAlignTopOrLeft = true; mMinMaxPosDirty = true; mAutoMoveToEdge = false; mClampInRange = false; mStartDragWindowPosition = Vector3.zero; mStartDragMousePosition = Vector3.zero; mMouseDownPos = Vector3.zero; mMoveNormal = Vector3.zero; mMoveSpeed = 0.0f; mMouseDown = false; mDraging = false; memset(mMinMaxPos, Vector3.zero); memset(mDisArray, 0.0f); }
protected float mMoveToEdgeSpeed = 5.0f; // 自动停靠到最近的边的速度 public txNGUIDragView() { mDragDirection = DRAG_DIRECTION.DD_HORIZONTAL; mClampType = CLAMP_TYPE.CT_EDGE; mMinRelativePos = -Vector3.one; mMaxRelativePos = Vector3.one; mReceiveScreenMouse = true; }
protected float mScrollSpeed; // 当前滚动速度 public NGUIScroll(LayoutScript script) { mScript = script; mState = SCROLL_STATE.SS_NONE; mDragDirection = DRAG_DIRECTION.DD_HORIZONTAL; mContainerList = new List <IScrollContainer>(); mItemList = new List <IScrollItem>(); }
protected bool mMouseDown; // 鼠标是否在窗口内按下,鼠标抬起或者离开窗口都会设置为false,鼠标按下时,跟随鼠标移动,鼠标放开时,按惯性移动 public UGUIScroll(LayoutScript script) { mScript = script; mState = SCROLL_STATE.NONE; mDragDirection = DRAG_DIRECTION.HORIZONTAL; mContainerList = new List <IScrollContainer>(); mItemList = new List <IScrollItem>(); mItemOnCenter = true; mFocusSpeedThreshhold = 2.0f; mDragSensitive = 1.0f; mAttenuateFactor = 2.0f; }
public override void resetProperty() { base.resetProperty(); // mScript不重置 //mScript = null; mBackground = null; mForeground = null; mThumb = null; mSliderStartCallback = null; mSliderEndCallback = null; mSliderCallback = null; mDirection = DRAG_DIRECTION.HORIZONTAL; mMode = SLIDER_MODE.FILL; mOriginForegroundSize = Vector2.zero; mOriginForegroundPosition = Vector3.zero; mSliderValue = 0.0f; mDraging = false; }
public WindowComponentDragView() { mDragDirection = DRAG_DIRECTION.DD_HORIZONTAL; mClampType = CLAMP_TYPE.CT_EDGE; mMinRelativePos = -Vector3.one; mMaxRelativePos = Vector3.one; mMinMaxPos = new Vector3[2]; mDisArray = new float[4]; mMutexDragView = new List <WindowComponentDragView>(); mDragAngleThreshold = toRadian(45.0f); mMoveSpeedScale = 1.0f; mAttenuateFactor = 2.0f; mMoveToEdgeSpeed = 5.0f; mDragAngleThreshold = 0.0f; mDragLengthThreshold = 10.0f; mAutoClampSpeed = 10.0f; mClampInner = true; mAlignTopOrLeft = true; }
public void setDragDirection(DRAG_DIRECTION direction) { mDragDirection = direction; }
public void setDragDirection(DRAG_DIRECTION direction) { mDragViewComponent.setDragDirection(direction); }
public void recalculateDragView <T>(List <T> itemList, Vector2 itemSize, float space, txUGUIObject dragViewParent, Vector2 viewportSize, int countPerLine = 0, float lineSpace = 0.0f, bool horiFirst = false) where T : IDragViewItem { // 计算拖拽窗口大小 int count = itemList.Count; int widthCount = 0; int heightCount = 0; DRAG_DIRECTION dragDirection = mDragViewComponent.getDragDirection(); if (dragDirection == DRAG_DIRECTION.DD_HORIZONTAL || dragDirection == DRAG_DIRECTION.DD_FREE) { widthCount = countPerLine; if (widthCount > 0) { heightCount = ceil((float)count / widthCount); } else { heightCount = 1; widthCount = count; } } else if (dragDirection == DRAG_DIRECTION.DD_VERTICAL || dragDirection == DRAG_DIRECTION.DD_FREE) { heightCount = countPerLine; if (heightCount > 0) { widthCount = ceil((float)count / heightCount); } else { widthCount = 1; heightCount = count; } } Vector2 windowSize = getWindowSize(); if (dragDirection == DRAG_DIRECTION.DD_HORIZONTAL || dragDirection == DRAG_DIRECTION.DD_FREE) { windowSize.x = itemSize.x * widthCount + space * (widthCount - 1); windowSize.y = itemSize.y * heightCount + lineSpace * (heightCount - 1); } else if (dragDirection == DRAG_DIRECTION.DD_VERTICAL || dragDirection == DRAG_DIRECTION.DD_FREE) { windowSize.x = itemSize.x * widthCount + lineSpace * (widthCount - 1); windowSize.y = itemSize.y * heightCount + space * (heightCount - 1); } clampMin(ref windowSize.x, 0.0f); clampMin(ref windowSize.y, 0.0f); setWindowSize(windowSize); // 设置所有子节点的位置 for (int i = 0; i < count; ++i) { Vector3 itemPos = itemList[i].getPosition(); if (dragDirection == DRAG_DIRECTION.DD_HORIZONTAL || dragDirection == DRAG_DIRECTION.DD_FREE) { // 排成多排 if (countPerLine > 0) { int horiIndex = horiFirst ? i % widthCount : i / heightCount; int vertIndex = horiFirst ? i / widthCount : i % heightCount; itemPos.x = (itemSize.x + space) * horiIndex + itemSize.x * 0.5f - windowSize.x * 0.5f; itemPos.y = (itemSize.y + lineSpace) * (heightCount - vertIndex - 1) + itemSize.y * 0.5f - windowSize.y * 0.5f; } // 只排一排 else { itemPos.x = (itemSize.x + space) * i + itemSize.x * 0.5f - windowSize.x * 0.5f; } } if (dragDirection == DRAG_DIRECTION.DD_VERTICAL || dragDirection == DRAG_DIRECTION.DD_FREE) { // 排成多列 if (countPerLine > 0) { int horiIndex = horiFirst ? i % widthCount : i / heightCount; int vertIndex = horiFirst ? i / widthCount : i % heightCount; itemPos.x = (itemSize.x + lineSpace) * (horiIndex - widthCount - 1) + itemSize.x * 0.5f - windowSize.x * 0.5f; itemPos.y = (itemSize.y + space) * vertIndex + itemSize.y * 0.5f - windowSize.y * 0.5f; } // 排成一列 else { itemPos.y = (itemSize.y + space) * (count - i - 1) + itemSize.y * 0.5f - windowSize.y * 0.5f; } } itemList[i].setPosition(itemPos); } // 重新计算拖拽窗口父节点的大小和位置,用于限定拖拽窗口的拖拽范围 Vector3 parentPos = dragViewParent.getPosition(); Vector2 parentSize = Vector2.zero; autoAdjustParent(ref parentPos, ref parentSize, viewportSize); dragViewParent.setWindowSize(parentSize); OT.MOVE(dragViewParent, parentPos); autoResetPosition(); }
public UGUISlider(LayoutScript script) { mScript = script; mDirection = DRAG_DIRECTION.HORIZONTAL; mMode = SLIDER_MODE.FILL; }