// 用于接收NGUI处理的输入事件 #if USE_NGUI public void registeBoxColliderNGUI(txNGUIObject obj, UIEventListener.VoidDelegate clickCallback, UIEventListener.BoolDelegate pressCallback = null, UIEventListener.BoolDelegate hoverCallback = null) { if (obj.getCollider() == null) { logInfo("window must has box collider that can registeBoxColliderNGUI!"); return; } obj.setClickCallback(clickCallback); obj.setPressCallback(pressCallback); obj.setHoverCallback(hoverCallback); }
protected bool mUseAnchor; // 是否启用锚点来自动调节窗口的大小和位置 public GameLayoutManager(string name) : base(name) { mUseAnchor = true; mScriptMappingList = new Dictionary <Type, List <LAYOUT> >(); mScriptRegisteList = new Dictionary <LAYOUT, Type>(); mLayoutTypeToName = new Dictionary <LAYOUT, string>(); mLayoutNameToType = new Dictionary <string, LAYOUT>(); mLayoutList = new Dictionary <LAYOUT, GameLayout>(); mLayoutAsyncList = new Dictionary <string, LayoutAsyncInfo>(); mBackBlurLayoutList = new List <GameLayout>(); // 在构造中获取UI根节点,确保其他组件能在任意时刻正常访问 mUGUIRoot = LayoutScript.newUIObject <txUGUICanvas>(null, null, getGameObject(null, CommonDefine.UGUI_ROOT, true)); #if USE_NGUI mNGUIRoot = LayoutScript.newUIObject <txNGUIObject>(null, null, getGameObject(null, CommonDefine.NGUI_ROOT, true)); mNGUIRootComponent = mNGUIRoot.getUnityComponent <UIRoot>(false); #endif }
public override void destroy() { foreach (var item in mLayoutList) { item.Value.destroy(); } mLayoutList.Clear(); mLayoutTypeToName.Clear(); mLayoutNameToType.Clear(); mLayoutAsyncList.Clear(); // 销毁UI摄像机 mCameraManager.destroyCamera(mCameraManager.getUICamera(true)); mCameraManager.destroyCamera(mCameraManager.getUICamera(false)); #if USE_NGUI txUIObject.destroyWindowSingle(mNGUIRoot, false); mNGUIRoot = null; #endif txUIObject.destroyWindowSingle(mUGUIRoot, false); mUGUIRoot = null; base.destroy(); }
public void init(txNGUIObject background, txNGUIObject foreground, txNGUIObject thumb, SLIDER_MODE mode) { mMode = mode; mBackground = background; mForeground = foreground; mThumb = thumb; if (mThumb != null && mThumb.getParent() != mForeground) { logError("Foreground must be parent of Thumb"); return; } if (mMode == SLIDER_MODE.SM_SIZING) { mOriginForegroundSize = mForeground.getWindowSize(); mOriginForegroundPosition = mForeground.getPosition(); if (mBackground == null) { logError("Background can not be null while slider mode is SM_SIZING"); return; } if (mForeground.getParent() != mBackground) { logError("Background must be parent of Foreground"); return; } } if (mBackground != null) { mBackground.setOnMouseDown(onMouseDown); mBackground.setOnScreenMouseUp(onScreenMouseUp); mBackground.setOnMouseMove(onMouseMove); if (mBackground.getCollider() != null) { mScript.registeBoxCollider(mBackground); } } }