示例#1
0
 // 注册碰撞器,只有注册了的碰撞器才会进行检测
 public void registeBoxCollider(txUIObject button, UIClickCallback clickCallback = null,
                                UIPressCallback pressCallback = null, UIHoverCallback hoverCallback = null)
 {
     if (mUseGlobalTouch)
     {
         button.setClickCallback(clickCallback);
         button.setPressCallback(pressCallback);
         button.setHoverCallback(hoverCallback);
         if (!mButtonCallbackList.Contains(button))
         {
             mButtonCallbackList.Add(button);
             UIDepth depth = new UIDepth(button.getLayout().getRenderOrder(), button.getDepth());
             if (!mButtonOrderList.ContainsKey(depth))
             {
                 mButtonOrderList.Add(depth, new List <txUIObject>());
             }
             mButtonOrderList[depth].Add(button);
         }
     }
     // 如果不使用
     else
     {
         logError("Not Active Global Touch! use public void registeBoxCollider(txUIObject button, " +
                  "UIEventListener.VoidDelegate clickCallback = null,UIEventListener.BoolDelegate pressCallback = null, " +
                  "UIEventListener.BoolDelegate hoverCallback = null) instead");
     }
 }
示例#2
0
 //--------------------------------------------------------------------------------------------------------------
 protected override void applyScreenPosition(ref Vector3 screenPos)
 {
     if (mMovable)
     {
         Vector3 pos = screenPosToWindowPos(screenPos - mDragMouseOffset, mWindow.getParent(), true, mWindow.getLayout().isNGUI());
         mWindow.setPosition(pos);
     }
 }
示例#3
0
 // 注销碰撞器
 public void unregisteBoxCollider(txUIObject button)
 {
     if (mButtonCallbackList.Contains(button))
     {
         mButtonCallbackList.Remove(button);
         UIDepth depth = new UIDepth(button.getLayout().getRenderOrder(), button.getDepth());
         mButtonOrderList[depth].Remove(button);
     }
 }
示例#4
0
    public void notifyButtonDepthChanged(txUIObject button, int lastDepth)
    {
        // 如果之前没有记录过,则不做判断
        UIDepth oldDepth = new UIDepth(button.getLayout().getRenderOrder(), lastDepth);

        if (!mButtonOrderList.ContainsKey(oldDepth) || !mButtonOrderList[oldDepth].Contains(button))
        {
            return;
        }
        // 移除旧的按钮
        mButtonOrderList[oldDepth].Remove(button);
        // 添加新的按钮
        UIDepth newDepth = new UIDepth(button.getLayout().getRenderOrder(), button.getDepth());

        if (!mButtonOrderList.ContainsKey(newDepth))
        {
            mButtonOrderList.Add(newDepth, new List <txUIObject>());
        }
        mButtonOrderList[newDepth].Add(button);
    }
    //------------------------------------------------------------------------------------------------------------------------------------------
    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);
    }
示例#6
0
    public txUIObject getHoverWindow(Vector3 pos, txUIObject ignoreWindow = null)
    {
        // 返回Layout深度最大的,也就是最靠前的窗口
        List <txUIObject> boxList       = globalRaycast(pos);
        txUIObject        forwardButton = null;

        foreach (var button in boxList)
        {
            GameLayout layout = button.getLayout();
            if (ignoreWindow != button && (forwardButton == null || layout.getRenderOrder() > forwardButton.getLayout().getRenderOrder()))
            {
                forwardButton = button;
            }
        }
        return(forwardButton);
    }