/// <summary> /// Create a brand-new UI hierarchy. /// </summary> static public GameObject CreateNewUI(CameraType type) { UIPanel p = NGUITools.CreateUI(type == CameraType.Advanced3D, NGUISettings.layer); Selection.activeGameObject = p.gameObject; return(Selection.activeGameObject); }
private static int CreateUI(IntPtr L) { int num = LuaDLL.lua_gettop(L); if (num == 1) { bool boolean = LuaScriptMgr.GetBoolean(L, 1); UIPanel obj = NGUITools.CreateUI(boolean); LuaScriptMgr.Push(L, obj); return(1); } if (num == 2) { bool boolean2 = LuaScriptMgr.GetBoolean(L, 1); int layer = (int)LuaScriptMgr.GetNumber(L, 2); UIPanel obj2 = NGUITools.CreateUI(boolean2, layer); LuaScriptMgr.Push(L, obj2); return(1); } if (num == 3) { Transform trans = (Transform)LuaScriptMgr.GetUnityObject(L, 1, typeof(Transform)); bool boolean3 = LuaScriptMgr.GetBoolean(L, 2); int layer2 = (int)LuaScriptMgr.GetNumber(L, 3); UIPanel obj3 = NGUITools.CreateUI(trans, boolean3, layer2); LuaScriptMgr.Push(L, obj3); return(1); } LuaDLL.luaL_error(L, "invalid arguments to method: NGUITools.CreateUI"); return(0); }
public static int CreateUI(int width, int height) { var p = NGUITools.CreateUI(false); var uiCamera = p.GetComponentInChildren <UICamera>(); var camera = uiCamera.GetComponent <Camera>(); camera.clearFlags = CameraClearFlags.Depth; UnityEngine.Object.DestroyImmediate(camera.GetComponent <AudioListener>()); var uiRoot = p.GetComponent <UIRoot>(); uiRoot.scalingStyle = UIRoot.Scaling.Constrained; uiRoot.manualWidth = width; uiRoot.manualHeight = height; float screenAspectRatio = (Screen.width * 1.0f) / Screen.height; float designAspectRatio = (width * 1.0f) / height; if ((screenAspectRatio * 100) < (designAspectRatio * 100)) { uiRoot.fitWidth = true; uiRoot.fitHeight = false; } else if ((screenAspectRatio * 100) > (designAspectRatio * 100)) { uiRoot.fitWidth = false; uiRoot.fitHeight = true; } return(LuaReference.Add(p.gameObject)); }
void CreateUI() { //创建根节点 this.Window = NGUITools.CreateUI(false).gameObject; //在根节点上创建一个UIScrollView子控件 UIScrollView scrollView = NGUITools.AddChild <UIScrollView>(this.Window); //在滚动视图上添加UIGrid子控件,来调整布局 UIGrid grid = NGUITools.AddChild <UIGrid>(scrollView.gameObject); //设置grid表格的布局方向 grid.arrangement = UIGrid.Arrangement.Horizontal; grid.cellWidth = 100.0f; grid.cellHeight = 100.0f; grid.animateSmoothly = false; //在Grid表格上添加20个Label对象 for (int i = 0; i < 10; i++) { CreateLabelItem(Random.Range(100, 999).ToString(), grid.gameObject); } //重新排版 grid.Reposition(); }
static public Asset Load(string name) { Asset asset = AssetMgr.Load(name); if (asset == null) { return(null); } asset.OnAssetLoaded = delegate(Object obj) { if (uiRoot == null) { uiRoot = NGUITools.CreateUI(false); GameObject.DontDestroyOnLoad(uiRoot.gameObject); //uiRoot.camera.audio.enabled = false; AudioListener al = (AudioListener)uiRoot.GetComponentInChildren <AudioListener>(); al.enabled = false; } GameObject go = NGUITools.AddChild(uiRoot.gameObject, obj as GameObject); go.name = go.name.Replace("(Clone)", ""); }; return(asset); }
static int CreateUI(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1) { bool arg0 = LuaScriptMgr.GetBoolean(L, 1); UIPanel o = NGUITools.CreateUI(arg0); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2) { bool arg0 = LuaScriptMgr.GetBoolean(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); UIPanel o = NGUITools.CreateUI(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 3) { Transform arg0 = (Transform)LuaScriptMgr.GetUnityObject(L, 1, typeof(Transform)); bool arg1 = LuaScriptMgr.GetBoolean(L, 2); int arg2 = (int)LuaScriptMgr.GetNumber(L, 3); UIPanel o = NGUITools.CreateUI(arg0, arg1, arg2); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: NGUITools.CreateUI"); } return(0); }
public virtual void Init(UIControl.SecendLevelUIType st = UIControl.SecendLevelUIType.None) { panelDic = new Dictionary <string, IPanel>(); secendLevelPanelDic = new Dictionary <string, IPanel>(); deleteDic = new Dictionary <string, IPanel>(); UIPanel rootPanel = NGUITools.CreateUI(false, LayerMask.NameToLayer(GameDefines.LayerNGUI)); rootPanel.name = "UI Root"; UIRoot uiRoot = rootPanel.gameObject.GetComponent <UIRoot>(); uiRoot.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles; uiRoot.manualHeight = (Screen.height > 640 ? 768 : 640); uiRoot.minimumHeight = (Screen.height > 640 ? 768 : 640); uiRoot.maximumHeight = 768; // add Effect Camera /* GameObject effectCameraObj = new GameObject("EffectCamera"); * effectCameraObj.layer = LayerMask.NameToLayer (GameDefines.LayerNGUI); * int mask = (1 << LayerMask.NameToLayer (GameDefines.LayerEffect)); * effectCameraObj.transform.parent = rootPanel.transform; * Camera effectCamera = effectCameraObj.AddComponent<Camera>(); * effectCamera.clearFlags = CameraClearFlags.Depth; * effectCamera.cullingMask = mask; * effectCamera.orthographic = true; * effectCamera.orthographicSize = 1.0f; * effectCamera.nearClipPlane = -10f; * effectCamera.farClipPlane = 10f; * effectCamera.depth = 2; * * // add Another UICamera * GameObject otherUICameraObj = new GameObject("OtherUICamera"); * otherUICameraObj.layer = LayerMask.NameToLayer(GameDefines.LayerNGUI); * int maskUI = (1 << LayerMask.NameToLayer(GameDefines.LayerHigherUI)); * otherUICameraObj.transform.parent = rootPanel.transform; * Camera otherUICamera = otherUICameraObj.AddComponent<Camera>(); * otherUICamera.clearFlags = CameraClearFlags.Depth; * otherUICamera.cullingMask = maskUI; * otherUICamera.orthographic = true; * otherUICamera.orthographicSize = 1.0f; * otherUICamera.nearClipPlane = -10f; * otherUICamera.farClipPlane = 10f; * otherUICamera.depth = 3; * UICamera uiCamera = otherUICameraObj.AddComponent<UICamera>(); * uiCamera.enabled = false; * //uiCamera.eventReceiverMask = (1 << LayerMask.NameToLayer(GameDefines.LayerHigherUI)); * * GameObject obj = Resources.Load<GameObject>(@"UI/LightPanel"); * if (null != obj) * NGUITools.AddChild(effectCameraObj, obj); */ // 设置UIControl里的静态变量 GameObject uiCameraObj = GameObject.Find(uiCameraPath); UIControl.CameraUI = uiCameraObj.GetComponent <Camera>(); // UIControl.CameraUIFx = effectCamera; //UIControl.CameraHigherUI = otherUICameraObj.GetComponent<Camera>(); }
// Use this for initialization void Start() { //创建程序窗口 this.Window = NGUITools.CreateUI(false); //创建背包滚动视图 this.Packet = new LONGUIPacketController(this.Window.gameObject); }
public static UIPanel Find(Transform trans, bool createIfMissing, int layer) { UIPanel uIPanel = NGUITools.FindInParents <UIPanel>(trans); if (uIPanel != null) { return(uIPanel); } return((!createIfMissing) ? null : NGUITools.CreateUI(trans, /*advanced3D:*/ false, layer)); }
/// <summary> /// Find the UIPanel responsible for handling the specified transform. /// </summary> static public UIPanel Find (Transform trans, bool createIfMissing, int layer) { UIPanel panel = null; while (panel == null && trans != null) { panel = trans.GetComponent<UIPanel>(); if (panel != null) return panel; if (trans.parent == null) break; trans = trans.parent; } return createIfMissing ? NGUITools.CreateUI(trans, false, layer) : null; }
void CreateUI() { UIPanel p = NGUITools.CreateUI(false, (int)GameLayer.UICamera); p.tag = "UIRoot"; var root = p.GetComponent <UIRoot> (); root.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles; root.manualWidth = 1024; root.manualHeight = 768; root.fitWidth = true; root.fitHeight = true; }
void AddRoot() { if (UIRoot.list.Count > 0) { Destroy(UIRoot.list[0].gameObject); UIRoot.list.Clear(); UIPanel.list.Clear(); } NGUITools.CreateUI(false); mRoot = UIRoot.list[0]; NGUITools.SetLayer(mRoot.gameObject, GTLayer.LAYER_UI); mRoot.scalingStyle = UIRoot.Scaling.Flexible; mRoot.minimumHeight = 320; mRoot.maximumHeight = 4096; mRoot.transform.localPosition = new Vector3(0, 0, -10000); NGUICamera = UICamera.eventHandler.cachedCamera; NGUICamera.clearFlags = CameraClearFlags.Depth; NGUICamera.depth = DEPTH_CAM_2DUICAMERA; NGUICamera.nearClipPlane = -10; NGUICamera.farClipPlane = 1200; DontDestroyOnLoad(mRoot); List <Transform> childs = new List <Transform>(); for (int i = 0; i < mRoot.transform.childCount; i++) { Transform cc = mRoot.transform.GetChild(i); if (cc != NGUICamera.transform) { childs.Add(cc); } } for (int i = 0; i < NGUICamera.transform.childCount; i++) { Transform cc = NGUICamera.transform.GetChild(i); childs.Add(cc); } while (childs.Count > 0) { Transform child = childs[0]; childs.Remove(child.transform); GameObject.Destroy(child.gameObject); } mAnchor = mRoot.gameObject.AddChild().transform; mAnchor.gameObject.name = "Anchor"; mAnchor.localPosition = new Vector3(0, 0, 0); mAnchor.localScale = Vector3.one; mAnchor.localRotation = Quaternion.identity; }
public static UIPanel Find(Transform trans, bool createIfMissing, int layer) { UIPanel uIPanel = NGUITools.FindInParents <UIPanel>(trans); if (uIPanel != null) { return(uIPanel); } while (trans.parent != null) { trans = trans.parent; } return((!createIfMissing) ? null : NGUITools.CreateUI(trans, false, layer)); }
public static UIPanel Find(Transform trans, Boolean createIfMissing, Int32 layer) { UIPanel uipanel = NGUITools.FindInParents <UIPanel>(trans); if (uipanel != (UnityEngine.Object)null) { return(uipanel); } while (trans.parent != (UnityEngine.Object)null) { trans = trans.parent; } return((!createIfMissing) ? null : NGUITools.CreateUI(trans, false, layer)); }
/** * 创建UIRoot */ void CreatRoot() { //通过创建UIPanel来创建UIRoot UIPanel panl = NGUITools.CreateUI(false); UIRoot root = panl.GetComponent <UIRoot> (); //设置UIRoot的缩放模式为Flexible root.scalingStyle = UIRoot.Scaling.Flexible; //设置最小高度 root.minimumHeight = 320; //设置最大高度 root.maximumHeight = 960; //设置UIRoot当屏幕为竖直方向时,缩放UI root.shrinkPortraitUI = true; //设置UIRoot的屏幕适配为像素 root.adjustByDPI = true; }
static public int CreateUI_s(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { System.Boolean a1; checkType(l, 1, out a1); var ret = NGUITools.CreateUI(a1); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { System.Boolean a1; checkType(l, 1, out a1); System.Int32 a2; checkType(l, 2, out a2); var ret = NGUITools.CreateUI(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { UnityEngine.Transform a1; checkType(l, 1, out a1); System.Boolean a2; checkType(l, 2, out a2); System.Int32 a3; checkType(l, 3, out a3); var ret = NGUITools.CreateUI(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public static GameObject FindUIRoot() { #if UGUI Canvas rootCanvas = GameObject.FindObjectOfType <Canvas>(); if (rootCanvas != null) { return(rootCanvas.gameObject); } return(new GameObject("UIRoot(UGUI)")); #elif NGUI UIRoot root = GameObject.FindObjectOfType <UIRoot>(); if (root == null) { NGUITools.CreateUI(false); } return(GameObject.FindObjectOfType <UICamera>().gameObject); #endif return(null); }
public static UIPanel Find(Transform trans, bool createIfMissing, int layer) { UIPanel uIPanel = null; while (uIPanel == null && trans != null) { uIPanel = trans.GetComponent <UIPanel>(); if (uIPanel != null) { return(uIPanel); } if (trans.parent == null) { break; } trans = trans.parent; } return((!createIfMissing) ? null : NGUITools.CreateUI(trans, false, layer)); }
private static int CreateUI(IntPtr L) { int result; try { int num = LuaDLL.lua_gettop(L); if (num == 1 && TypeChecker.CheckTypes(L, 1, typeof(bool))) { bool advanced3D = LuaDLL.lua_toboolean(L, 1); UIPanel obj = NGUITools.CreateUI(advanced3D); ToLua.Push(L, obj); result = 1; } else if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(bool), typeof(int))) { bool advanced3D2 = LuaDLL.lua_toboolean(L, 1); int layer = (int)LuaDLL.lua_tonumber(L, 2); UIPanel obj2 = NGUITools.CreateUI(advanced3D2, layer); ToLua.Push(L, obj2); result = 1; } else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(Transform), typeof(bool), typeof(int))) { Transform trans = (Transform)ToLua.ToObject(L, 1); bool advanced3D3 = LuaDLL.lua_toboolean(L, 2); int layer2 = (int)LuaDLL.lua_tonumber(L, 3); UIPanel obj3 = NGUITools.CreateUI(trans, advanced3D3, layer2); ToLua.Push(L, obj3); result = 1; } else { result = LuaDLL.luaL_throw(L, "invalid arguments to method: NGUITools.CreateUI"); } } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
/// <summary> /// 创建ngui窗口Root /// </summary> /// <param name="layer"></param> /// <returns></returns> private Transform CreateNguiWindowContainer(int layer, Transform parentTs) { var ui2d = NGUITools.CreateUI(false, layer); var ts = ui2d.transform; GameObjectUtile.ResetTransformInfo(ts, parentTs); var uiroot = ui2d.GetComponent <UIRoot>(); uiroot.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles; uiroot.manualWidth = (int)ScreenSize.x; uiroot.manualHeight = (int)ScreenSize.y; uiroot.fitWidth = true; uiroot.fitHeight = true; var uiC = ui2d.GetComponentInChildren <Camera>(); uiC.clearFlags = CameraClearFlags.Depth; uiC.depth = 100; uiC.gameObject.AddComponent <YxBaseCameraAssist>(); return(ts); }
/// <summary> /// 创建移动攻击等控制UI /// </summary> void CreateUI() { //初始化UIRoot UIPanel p = NGUITools.CreateUI(false, (int)GameLayer.UICamera); p.tag = "UIRoot"; var root = p.GetComponent <UIRoot> (); root.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles; root.manualWidth = 1280; root.manualHeight = 720; root.fitWidth = true; root.fitHeight = true; root.transform.position = new Vector3(100, 100, 0); var leftController = Object.Instantiate(Resources.Load <GameObject>("levelPublic/LeftController")) as GameObject; //leftController.transform.position = new Vector3(0,0.12f,0); //var rightController = GameObject.Instantiate(Resources.Load<GameObject>("levelPublic/RightController")) as GameObject; //rightController.transform.position = new Vector3(0, 0.12f, 0); }
static int CreateUI(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(bool))) { bool arg0 = LuaDLL.lua_toboolean(L, 1); UIPanel o = NGUITools.CreateUI(arg0); ToLua.Push(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(bool), typeof(int))) { bool arg0 = LuaDLL.lua_toboolean(L, 1); int arg1 = (int)LuaDLL.lua_tonumber(L, 2); UIPanel o = NGUITools.CreateUI(arg0, arg1); ToLua.Push(L, o); return(1); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Transform), typeof(bool), typeof(int))) { UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1); bool arg1 = LuaDLL.lua_toboolean(L, 2); int arg2 = (int)LuaDLL.lua_tonumber(L, 3); UIPanel o = NGUITools.CreateUI(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: NGUITools.CreateUI")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 创建移动攻击等控制UI /// </summary> void CreateUI() { //初始化UIRoot UIPanel p = NGUITools.CreateUI(false, (int)GameLayer.UICamera); p.tag = "UIRoot"; var root = p.GetComponent <UIRoot> (); root.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles; root.manualWidth = 1024; root.manualHeight = 768; root.fitWidth = true; root.fitHeight = true; //删除的对象不能放在Don'tDestroy 下面 var vjoyController = Resources.Load <GameObject> ("levelPublic/VirtualJoystick"); //var ng = GameObject.Instantiate(vjoyController); // as GameObject; //ng.transform.parent = transform; //vjoyController.transform.parent = transform; Log.GUI("Init virtual Joy stick " + vjoyController); }
private void LoadDependRoot() { mRootPanel = NGUITools.CreateUI(null, false, LayerMask.NameToLayer("NGUI")); if (UIRoot.list.Count > 0) { NGUIRoot = UIRoot.list[0]; WindowRoot = UITools.CreateObject("WndRoot", NGUIRoot.gameObject); } NGUIRoot.tag = "NGUIRoot"; NGUICamera = NGUIRoot.GetComponentInChildren <Camera>(); NGUICamera.cullingMask = 1 << LayerMask.NameToLayer("NGUI"); NGUICamera.clearFlags = CameraClearFlags.Depth; NGUIRoot.manualWidth = 960; NGUIRoot.manualHeight = 640; NGUIRoot.fitHeight = true; NGUIRoot.scalingStyle = UIRoot.Scaling.ConstrainedOnMobiles; isLoadDependObject = true; }
public Transform CreateUI(int layer) { return(NGUITools.CreateUI(false, layer).transform); }
// Token: 0x060032D1 RID: 13009 RVA: 0x000FF798 File Offset: 0x000FDB98 public static UIPanel CreateUI(bool advanced3D, int layer) { return(NGUITools.CreateUI(null, advanced3D, layer)); }
// Token: 0x060032D0 RID: 13008 RVA: 0x000FF78E File Offset: 0x000FDB8E public static UIPanel CreateUI(bool advanced3D) { return(NGUITools.CreateUI(null, advanced3D, -1)); }
/// <summary> /// Find the UIPanel responsible for handling the specified transform. /// </summary> static public UIPanel Find (Transform trans, bool createIfMissing, int layer) { UIPanel panel = trans.GetComponentInParent<UIPanel>(); if (panel != null) return panel; return createIfMissing ? NGUITools.CreateUI(trans, false, layer) : null; }