public static UIRect findNGUIParentRect(GameObject obj) { #if MAKE_CS_DLL return((UIRect)callStatic(UTILITY_WIDGET, "findNGUIParentRect", new object[] { obj })); #else return(WidgetUtility.findNGUIParentRect(obj)); #endif }
//------------------------------------------------------------------------------------------------------------------------------------------ protected Vector3[] getLocalMinMaxPixelPos() { if (mMinMaxPosDirty) { bool isNGUI = mWindow.getLayout().isNGUI(); Vector2 parentWidgetSize = Vector2.zero; if (isNGUI) { #if USE_NGUI // 获得第一个带widget的父节点的rect if (mParentRect == null) { mParentRect = WidgetUtility.findNGUIParentRect(mWindow.getObject()); } parentWidgetSize = WidgetUtility.getNGUIRectSize(mParentRect); #endif } else { parentWidgetSize = mWindow.getParent().getWindowSize(); } // 计算父节点的世界缩放 Vector2 worldScale = getMatrixScale(mWindow.getTransform().parent.localToWorldMatrix); txUIObject root = mLayoutManager.getUIRoot(isNGUI); Vector2 uiRootScale = root.getTransform().localScale; Vector2 parentScale = worldScale / uiRootScale; // 计算移动的位置范围 Vector2 minPos = parentWidgetSize * 0.5f * mMinRelativePos / parentScale; Vector2 maxPos = parentWidgetSize * 0.5f * mMaxRelativePos / parentScale; if (mClampType == CLAMP_TYPE.CT_EDGE) { Vector2 thisSize = mWindow.getWindowSize(true); minPos += thisSize * 0.5f; maxPos -= thisSize * 0.5f; if (!mClampInner) { swap(ref minPos, ref maxPos); } } else if (mClampType == CLAMP_TYPE.CT_CENTER) { } mMinMaxPos[0] = minPos; mMinMaxPos[1] = maxPos; mMinMaxPosDirty = false; } return(mMinMaxPos); }