public void notifyButtonDepthChanged(txUIObject button, int lastDepth) { // 如果之前没有记录过,则不做判断 if (!mButtonOrderList.ContainsKey(lastDepth) || !mButtonOrderList[lastDepth].Contains(button)) { return; } // 移除旧的按钮 mButtonOrderList[lastDepth].Remove(button); // 添加新的按钮 if (!mButtonOrderList.ContainsKey(button.getDepth())) { mButtonOrderList.Add(button.getDepth(), new List <txUIObject>()); } mButtonOrderList[button.getDepth()].Add(button); }
// 注册碰撞器,只有注册了的碰撞器才会进行检测 public void registeBoxCollider(txUIObject button, BoxColliderClickCallback clickCallback = null, BoxColliderPressCallback pressCallback = null, BoxColliderHoverCallback hoverCallback = null) { if (mUseGlobalTouch) { if (!mButtonCallbackList.ContainsKey(button)) { ColliderCallBack colliderCallback = new ColliderCallBack(); colliderCallback.mButton = button; colliderCallback.mClickCallback = clickCallback; colliderCallback.mHoverCallback = hoverCallback; colliderCallback.mPressCallback = pressCallback; mButtonCallbackList.Add(button, colliderCallback); UIDepth depth = new UIDepth(button.mLayout.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"); } }
// 返回值是最后一个窗口的深度值,ignoreInactive表示是否忽略未启用的节点 protected int setUIChildDepth(txUIObject ui, int uiDepth, bool includeSelf = true, bool ignoreInactive = false) { // NGUI不需要重新设置所有节点的深度 if (mIsNGUI) { return(0); } // 先设置当前窗口的深度 if (includeSelf) { ui.setDepth(uiDepth); } // 再设置子窗口的深度 int endDepth = ui.getDepth(); if (ignoreInactive && !ui.isActive()) { return(endDepth); } Transform transform = ui.getTransform(); int childCount = transform.childCount; for (int i = 0; i < childCount; ++i) { txUIObject uiObj = getUIObject(transform.GetChild(i).gameObject); if (uiObj != null) { endDepth = setUIChildDepth(uiObj, endDepth + 1); } } return(endDepth); }
// 返回值是最后一个窗口的深度值,ignoreInactive表示是否忽略未启用的节点 protected int setUIChildDepth(txUIObject window, int uiDepth, bool includeSelf = true, bool ignoreInactive = false) { // NGUI不需要重新设置所有节点的深度 if (mIsNGUI) { return(0); } // 先设置当前窗口的深度 if (includeSelf) { window.setDepth(uiDepth); } // 再设置子窗口的深度 int endDepth = window.getDepth(); if (ignoreInactive && !window.isActive()) { return(endDepth); } var children = window.getChildList(); int childCount = children.Count; for (int i = 0; i < childCount; ++i) { endDepth = setUIChildDepth(children[i], endDepth + 1, true, ignoreInactive); } return(endDepth); }
// 注册碰撞器,只有注册了的碰撞器才会进行检测 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"); } }
// 注销碰撞器 public void unregisteBoxCollider(txUIObject button) { if (mButtonCallbackList.ContainsKey(button)) { mButtonCallbackList.Remove(button); mButtonOrderList[button.getDepth()].Remove(button); } }
// 节点在当前父节点中的位置有改变 public void notifyObjectOrderChanged(txUIObject parent, bool ignoreInactive = false) { if (parent == null) { return; } setUIChildDepth(parent, parent.getDepth(), parent != mRoot, ignoreInactive); }
// 注册碰撞器,只有注册了的碰撞器才会进行检测 public void registeBoxCollider(txUIObject button, BoxColliderClickCallback clickCallback = null, BoxColliderHoverCallback hoverCallback = null, BoxColliderPressCallback pressCallback = null) { if (!mButtonCallbackList.ContainsKey(button)) { ColliderCallBack colliderCallback = new ColliderCallBack(); colliderCallback.mButton = button; colliderCallback.mClickCallback = clickCallback; colliderCallback.mHoverCallback = hoverCallback; colliderCallback.mPressCallback = pressCallback; mButtonCallbackList.Add(button, colliderCallback); if (!mButtonOrderList.ContainsKey(button.getDepth())) { mButtonOrderList.Add(button.getDepth(), new List <txUIObject>()); } mButtonOrderList[button.getDepth()].Add(button); } }
// 注销碰撞器 public void unregisteBoxCollider(txUIObject button) { if (mButtonCallbackList.ContainsKey(button)) { mButtonCallbackList.Remove(button); UIDepth depth = new UIDepth(button.mLayout.getRenderOrder(), button.getDepth()); mButtonOrderList[depth].Remove(button); } }
public void notifyButtonDepthChanged(txUIObject button, int lastDepth) { // 如果之前没有记录过,则不做判断 UIDepth oldDepth = new UIDepth(button.mLayout.getRenderOrder(), lastDepth); if (!mButtonOrderList.ContainsKey(oldDepth) || !mButtonOrderList[oldDepth].Contains(button)) { return; } // 移除旧的按钮 mButtonOrderList[oldDepth].Remove(button); // 添加新的按钮 UIDepth newDepth = new UIDepth(button.mLayout.getRenderOrder(), button.getDepth()); if (!mButtonOrderList.ContainsKey(newDepth)) { mButtonOrderList.Add(newDepth, new List <txUIObject>()); } mButtonOrderList[newDepth].Add(button); }