private static int SetAnchor(IntPtr L) { int num = LuaDLL.lua_gettop(L); if (num == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(UIRect), typeof(GameObject))) { UIRect uIRect = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); GameObject anchor = (GameObject)LuaScriptMgr.GetLuaObject(L, 2); uIRect.SetAnchor(anchor); return(0); } if (num == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(UIRect), typeof(Transform))) { UIRect uIRect2 = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); Transform anchor2 = (Transform)LuaScriptMgr.GetLuaObject(L, 2); uIRect2.SetAnchor(anchor2); return(0); } if (num == 6) { UIRect uIRect3 = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); GameObject go = (GameObject)LuaScriptMgr.GetUnityObject(L, 2, typeof(GameObject)); int left = (int)LuaScriptMgr.GetNumber(L, 3); int bottom = (int)LuaScriptMgr.GetNumber(L, 4); int right = (int)LuaScriptMgr.GetNumber(L, 5); int top = (int)LuaScriptMgr.GetNumber(L, 6); uIRect3.SetAnchor(go, left, bottom, right, top); return(0); } LuaDLL.luaL_error(L, "invalid arguments to method: UIRect.SetAnchor"); return(0); }
//弹出一个消息 public void PopMsg(string msg, Color color) { float minY = m_StartY + (float)m_PopingObjs.Count * m_ItemHeight; if (IsSameItem(msg)) { return; } //将一些过矮的元素提升 foreach (TipItem curr in m_PopingObjs) { GameObject obj = curr.obj; if (obj.transform.localPosition.y < minY) { Vector3 pos = obj.transform.localPosition; pos.y = minY; obj.transform.localPosition = pos; } minY -= m_ItemHeight; } //创建item对象 GameObject item = GameObjectExtension.InstantiateFromPreobj(m_ItemMB, m_ItemMB.transform.parent.gameObject); item.SetActive(true); NGUITools.MarkParentAsChanged(item); TipItem newItem = new TipItem() { lostTime = 0, obj = item }; m_PopingObjs.Add(newItem); //设置标签 string[] findpath = new string[1]; findpath[0] = "Label"; GameObject lableObj = GameObjectExtension.FindChild(item.transform, findpath).gameObject; UILabel cmlabel = lableObj.GetComponent <UILabel>(); cmlabel.text = msg; cmlabel.color = color; //解除位置绑定关系 UIRect cm_rect = item.GetComponent <UIRect>(); cm_rect.SetAnchor((GameObject)null); if (!m_CoroutineIsDoing) { CoroutineManage.Single.StartCoroutine(coUpdate()); } }
protected abstract void OnShow(); // 显示UI protected virtual void SetAnchors() { UIRect rect = GetComponent <UIRect>(); if (rect != null && !rect.isAnchored) { Transform parent = transform.parent != null ? transform.parent : transform.root; rect.SetAnchor(parent.gameObject, 0, 0, 0, 0); } }
public static int SetAnchor(IntPtr l) { int result; try { int num = LuaDLL.pua_gettop(l); if (LuaObject.matchType(l, num, 2, typeof(GameObject))) { UIRect uIRect = (UIRect)LuaObject.checkSelf(l); GameObject anchor; LuaObject.checkType <GameObject>(l, 2, out anchor); uIRect.SetAnchor(anchor); LuaObject.pushValue(l, true); result = 1; } else if (LuaObject.matchType(l, num, 2, typeof(Transform))) { UIRect uIRect2 = (UIRect)LuaObject.checkSelf(l); Transform anchor2; LuaObject.checkType <Transform>(l, 2, out anchor2); uIRect2.SetAnchor(anchor2); LuaObject.pushValue(l, true); result = 1; } else if (num == 6) { UIRect uIRect3 = (UIRect)LuaObject.checkSelf(l); GameObject go; LuaObject.checkType <GameObject>(l, 2, out go); int left; LuaObject.checkType(l, 3, out left); int bottom; LuaObject.checkType(l, 4, out bottom); int right; LuaObject.checkType(l, 5, out right); int top; LuaObject.checkType(l, 6, out top); uIRect3.SetAnchor(go, left, bottom, right, top); LuaObject.pushValue(l, true); result = 1; } else { LuaObject.pushValue(l, false); LuaDLL.pua_pushstring(l, "No matched override function to call"); result = 2; } } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
// 将某个UI View添加到指定场景路径下,返回值表示是否成功 // 路径字符串从"UIRoot"开始并连接各层级的UI对象名,层级之间用'/'隔开。例如:"UIRoot/TheParentView" public bool AttachViewToPath(string path, UIView view) { if (view == null) { return(false); } string[] names = path.Split('/'); if (names.Length <= 0 || names[0] != "UIRoot") { return(false); } UIController UI = GameRoot.UI; Transform curNode = UI ? UI.transform : null; if (curNode == null) { return(false); } for (int i = 1; i < names.Length; ++i) { Transform childNode = curNode.FindChild(names[i]); if (childNode == null) { return(false); } curNode = childNode; } string viewName = view.ViewName; if (!_viewMap.ContainsKey(viewName)) { _viewMap.Add(viewName, view); } view.transform.SetParent(curNode, false); view.Path = path; UIRect rect = view.GetComponent <UIRect>(); if (rect != null) { rect.SetAnchor(curNode); } return(true); }
static public int SetAnchor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(UnityEngine.GameObject))) { UIRect self = (UIRect)checkSelf(l); UnityEngine.GameObject a1; checkType(l, 2, out a1); self.SetAnchor(a1); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(UnityEngine.Transform))) { UIRect self = (UIRect)checkSelf(l); UnityEngine.Transform a1; checkType(l, 2, out a1); self.SetAnchor(a1); pushValue(l, true); return(1); } else if (argc == 6) { UIRect self = (UIRect)checkSelf(l); UnityEngine.GameObject a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); System.Int32 a5; checkType(l, 6, out a5); self.SetAnchor(a1, a2, a3, a4, a5); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
private static int SetAnchor(IntPtr L) { int result; try { int num = LuaDLL.lua_gettop(L); if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(UIRect), typeof(GameObject))) { UIRect uIRect = (UIRect)ToLua.ToObject(L, 1); GameObject anchor = (GameObject)ToLua.ToObject(L, 2); uIRect.SetAnchor(anchor); result = 0; } else if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(UIRect), typeof(Transform))) { UIRect uIRect2 = (UIRect)ToLua.ToObject(L, 1); Transform anchor2 = (Transform)ToLua.ToObject(L, 2); uIRect2.SetAnchor(anchor2); result = 0; } else if (num == 6 && TypeChecker.CheckTypes(L, 1, typeof(UIRect), typeof(GameObject), typeof(int), typeof(int), typeof(int), typeof(int))) { UIRect uIRect3 = (UIRect)ToLua.ToObject(L, 1); GameObject go = (GameObject)ToLua.ToObject(L, 2); int left = (int)LuaDLL.lua_tonumber(L, 3); int bottom = (int)LuaDLL.lua_tonumber(L, 4); int right = (int)LuaDLL.lua_tonumber(L, 5); int top = (int)LuaDLL.lua_tonumber(L, 6); uIRect3.SetAnchor(go, left, bottom, right, top); result = 0; } else { result = LuaDLL.luaL_throw(L, "invalid arguments to method: UIRect.SetAnchor"); } } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
static int SetAnchor(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes <UnityEngine.GameObject>(L, 2)) { UIRect obj = (UIRect)ToLua.CheckObject <UIRect>(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.Transform>(L, 2)) { UIRect obj = (UIRect)ToLua.CheckObject <UIRect>(L, 1); UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 6) { UIRect obj = (UIRect)ToLua.CheckObject <UIRect>(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject)); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); int arg2 = (int)LuaDLL.luaL_checknumber(L, 4); int arg3 = (int)LuaDLL.luaL_checknumber(L, 5); int arg4 = (int)LuaDLL.luaL_checknumber(L, 6); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UIRect.SetAnchor")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetAnchor(IntPtr L) { int count = LuaDLL.lua_gettop(L); Type[] types0 = { typeof(UIRect), typeof(GameObject) }; Type[] types1 = { typeof(UIRect), typeof(Transform) }; if (count == 2 && LuaScriptMgr.CheckTypes(L, types0, 1)) { UIRect obj = LuaScriptMgr.GetNetObject <UIRect>(L, 1); GameObject arg0 = LuaScriptMgr.GetNetObject <GameObject>(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, types1, 1)) { UIRect obj = LuaScriptMgr.GetNetObject <UIRect>(L, 1); Transform arg0 = LuaScriptMgr.GetNetObject <Transform>(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 6) { UIRect obj = LuaScriptMgr.GetNetObject <UIRect>(L, 1); GameObject arg0 = LuaScriptMgr.GetNetObject <GameObject>(L, 2); int arg1 = (int)LuaScriptMgr.GetNumber(L, 3); int arg2 = (int)LuaScriptMgr.GetNumber(L, 4); int arg3 = (int)LuaScriptMgr.GetNumber(L, 5); int arg4 = (int)LuaScriptMgr.GetNumber(L, 6); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UIRect.SetAnchor"); } return(0); }
static int SetAnchor(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(UIRect), typeof(GameObject))) { UIRect obj = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); GameObject arg0 = (GameObject)LuaScriptMgr.GetLuaObject(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(UIRect), typeof(Transform))) { UIRect obj = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); Transform arg0 = (Transform)LuaScriptMgr.GetLuaObject(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 6) { UIRect obj = (UIRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIRect"); GameObject arg0 = (GameObject)LuaScriptMgr.GetUnityObject(L, 2, typeof(GameObject)); int arg1 = (int)LuaScriptMgr.GetNumber(L, 3); int arg2 = (int)LuaScriptMgr.GetNumber(L, 4); int arg3 = (int)LuaScriptMgr.GetNumber(L, 5); int arg4 = (int)LuaScriptMgr.GetNumber(L, 6); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UIRect.SetAnchor"); } return(0); }
static int SetAnchor(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UIRect), typeof(UnityEngine.GameObject))) { UIRect obj = (UIRect)ToLua.ToObject(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UIRect), typeof(UnityEngine.Transform))) { UIRect obj = (UIRect)ToLua.ToObject(L, 1); UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 2); obj.SetAnchor(arg0); return(0); } else if (count == 6 && ToLua.CheckTypes(L, 1, typeof(UIRect), typeof(UnityEngine.GameObject), typeof(float), typeof(float), typeof(float), typeof(float))) { UIRect obj = (UIRect)ToLua.ToObject(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); float arg1 = (float)LuaDLL.lua_tonumber(L, 3); float arg2 = (float)LuaDLL.lua_tonumber(L, 4); float arg3 = (float)LuaDLL.lua_tonumber(L, 5); float arg4 = (float)LuaDLL.lua_tonumber(L, 6); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4); return(0); } else if (count == 6 && ToLua.CheckTypes(L, 1, typeof(UIRect), typeof(UnityEngine.GameObject), typeof(int), typeof(int), typeof(int), typeof(int))) { UIRect obj = (UIRect)ToLua.ToObject(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); int arg4 = (int)LuaDLL.lua_tonumber(L, 6); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4); return(0); } else if (count == 9 && ToLua.CheckTypes(L, 1, typeof(UIRect), typeof(float), typeof(int), typeof(float), typeof(int), typeof(float), typeof(int), typeof(float), typeof(int))) { UIRect obj = (UIRect)ToLua.ToObject(L, 1); float arg0 = (float)LuaDLL.lua_tonumber(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); float arg2 = (float)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); float arg4 = (float)LuaDLL.lua_tonumber(L, 6); int arg5 = (int)LuaDLL.lua_tonumber(L, 7); float arg6 = (float)LuaDLL.lua_tonumber(L, 8); int arg7 = (int)LuaDLL.lua_tonumber(L, 9); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); return(0); } else if (count == 10 && ToLua.CheckTypes(L, 1, typeof(UIRect), typeof(UnityEngine.GameObject), typeof(float), typeof(int), typeof(float), typeof(int), typeof(float), typeof(int), typeof(float), typeof(int))) { UIRect obj = (UIRect)ToLua.ToObject(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); float arg1 = (float)LuaDLL.lua_tonumber(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); float arg3 = (float)LuaDLL.lua_tonumber(L, 5); int arg4 = (int)LuaDLL.lua_tonumber(L, 6); float arg5 = (float)LuaDLL.lua_tonumber(L, 7); int arg6 = (int)LuaDLL.lua_tonumber(L, 8); float arg7 = (float)LuaDLL.lua_tonumber(L, 9); int arg8 = (int)LuaDLL.lua_tonumber(L, 10); obj.SetAnchor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); return(0); } else { return(LuaDLL.tolua_error(L, "invalid arguments to method: UIRect.SetAnchor")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
IEnumerator coDoCmd() { while (m_Cmds.Count > 0) { var aInfo = m_Cmds[0]; m_Cmds.RemoveAt(0); var wndName = aInfo.name; var subID = ""; string[] sArray = aInfo.name.Split('&'); if (sArray.Length == 2) { wndName = sArray[0]; subID = '&' + sArray[1]; } if (!m_wndInfos.ContainsKey(aInfo.name)) { if (sArray.Length == 2) { wndInfo wInfo2 = (wndInfo)m_wndInfos[wndName].Clone(); wInfo2.name = aInfo.name; m_wndInfos.Add(wInfo2.name, wInfo2); } else { Debug.LogError("窗体注册信息不存在 " + wndName); continue; } } if (aInfo.needVisible != WShowType.hide && aInfo.needVisible != WShowType.destroy) { //标记是否第一次打开(包括释放后再打开) bool isFirstShow = false; //从最近隐藏记录中清除 if (m_wndLastHideTime.ContainsKey(wndName + subID)) { m_wndLastHideTime.Remove(wndName + subID); } isFirstShow = !m_wndInstances.ContainsKey(wndName + subID); //窗体不存在,则创建 if (isFirstShow) { IEnumerator it = LoadDepend(wndName); while (it.MoveNext()) { yield return(null); } wndInfo wInfo = m_wndInfos[wndName + subID]; //创建一个uipanel GameObject uipanel = new GameObject(wInfo.name + "_panel"); uipanel.transform.parent = UIRootObj.transform; uipanel.transform.localScale = new Vector3(1, 1, 1); uipanel.transform.localRotation = new Quaternion(0, 0, 0, 1); uipanel.transform.localPosition = new Vector3(0, 0, 0); uipanel.layer = LayerMask.NameToLayer("UI");//设置层 UIPanel cmpanel = uipanel.AddComponent <UIPanel>(); GameObject wnd_Obj = GameObjectExtension.InstantiateFromPacket(wInfo.dependPackets[1], wndName + ".prefab", uipanel); if (wnd_Obj == null) { //删除刚创建的uipanel GameObject.Destroy(uipanel); Debug.LogError(String.Format("实例化窗体错误, packet:{0} wndName:{1}", wInfo.dependPackets[1], wInfo.name)); throw new Exception(); } //设置新创建的panel锚点 { UIRect rectCM = uipanel.GetComponent <UIRect>(); rectCM.SetAnchor(UIRootObj, 0, 0, 0, 0); rectCM.updateAnchors = UIRect.AnchorUpdate.OnStart; } //设置预置锚点 const int safev = 1; { UIRect rectCM = wnd_Obj.GetComponent <UIRect>(); rectCM.SetAnchor(uipanel, -safev, -safev, safev, safev); rectCM.updateAnchors = UIRect.AnchorUpdate.OnStart; } //创建挡板 GameObject uibaffle; { uibaffle = new GameObject(wInfo.name + "_baffle"); uibaffle.layer = LayerMask.NameToLayer("UI");//设置层 uibaffle.transform.parent = uipanel.transform; uibaffle.transform.localScale = Vector3.one; uibaffle.transform.localRotation = Quaternion.identity; uibaffle.transform.localPosition = Vector3.zero; //增加碰撞盒 var cl = uibaffle.AddComponent <BoxCollider>(); //增加UIWidget组件 var cmBaffleWidget = uibaffle.AddComponent <UIWidget>(); cl.isTrigger = true; cmBaffleWidget.autoResizeBoxCollider = true; cmBaffleWidget.updateAnchors = UIRect.AnchorUpdate.OnStart; cmBaffleWidget.SetAnchor(uipanel, -safev, -safev, safev, safev);//设置锚点 cmBaffleWidget.depth = -99; } wnd_Obj.name = wndName + subID; wnd_Obj.SetActive(true); uipanel.SetActive(false); m_wndInstances.Add(wndName + subID, new Wnd(uipanel, uibaffle, wInfo)); if (aInfo.isWithBg)//再加一个gameobject的原因是如果做动画底板需要层级高于预制,底板会压在预制上 { //TODODO 图片放到了Resources目录 UITexture ut = NGUITools.AddWidget <UITexture>(uipanel, -99); Texture texure = Resources.Load <Texture>("zanting_jiashenceng"); ut.mainTexture = texure; UIStretch stretch = ut.gameObject.AddComponent <UIStretch>(); stretch.style = UIStretch.Style.Both; // set relative size bigger stretch.relativeSize = new Vector2(3, 3); } } //显示 Wnd wnd = m_wndInstances[wndName + subID]; if (aInfo.needVisible == WShowType.preLoad) { yield return(null); Wnd.OnPreLoadFinish.Call(wnd); } else if (aInfo.needVisible == WShowType.show) { wnd._Show(aInfo.duration); //等待窗体组件准备就绪 yield return(null); if (isFirstShow) { Wnd.OnShowFinish.Call(wnd); } else { Wnd.OnReOpenWnd.Call(wnd); } if (OnWndOpen != null) { OnWndOpen.Call(wndName); } } } else { if (m_wndInstances.ContainsKey(wndName + subID)) { //从最近隐藏记录中清除 if (aInfo.needVisible == WShowType.destroy && m_wndLastHideTime.ContainsKey(wndName + subID)) { m_wndLastHideTime.Remove(wndName + subID); } Wnd wnd = m_wndInstances[wndName + subID]; wnd._Hide(aInfo.duration, aInfo.needVisible, aInfo.PlantfromDetph); if (aInfo.needVisible == WShowType.hide) { Wnd.OnHideFinish.Call(wnd); } else if (aInfo.needVisible == WShowType.destroy) { Wnd.OnDestroyFinish.Call(wnd); } } } yield return(null); } m_coIsRuning = false; }