static void AddUlc(UILuaExporter parent, UILuaExporter expt) { if (parent == expt) { return; } int i = 0; if (parent.subCtrlList == null) { parent.subCtrlList = new List <UILuaExporter>(); } for (; i < parent.subCtrlList.Count; ++i) { if (parent.subCtrlList[i].name.Equals(expt.name)) { var p = parent.subCtrlList[i]; while (p.next != null) { p = p.next; } p.next = expt; break; } } if (i == parent.subCtrlList.Count) { parent.subCtrlList.Add(expt); } }
static int set_exporter(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); LuaBehaviour obj = (LuaBehaviour)o; UILuaExporter arg0 = (UILuaExporter)ToLua.CheckUnityObject(L, 2, typeof(UILuaExporter)); obj.exporter = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index exporter on a nil value" : e.Message)); } }
static int get_exporter(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); LuaBehaviour obj = (LuaBehaviour)o; UILuaExporter ret = obj.exporter; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index exporter on a nil value" : e.Message)); } }
static void FillLuaExporter(GameObject go, UILuaExporter parent, bool isRoot) { var expt = go.GetComponent <UILuaExporter>(); var currentParent = parent; if (expt != null) { if (go.name.StartsWith("_") || isRoot) { currentParent = expt; List <string> names = new List <string>(); List <UIWrapper> wraps = new List <UIWrapper>(); FindExport(go, ref names, ref wraps, true); expt.SetExport(names, wraps); expt.next = null; expt.subCtrlList = null; string exportName; if (isRoot) { exportName = go.name; } else { exportName = go.name.Substring(1, go.name.Length - 1); } expt.name = exportName; if (string.IsNullOrEmpty(expt.scriptName)) { expt.scriptName = exportName + "View"; } AddUlc(parent, expt); } } for (int i = 0; i < go.transform.childCount; ++i) { FillLuaExporter(go.transform.GetChild(i).gameObject, currentParent, false); } }
public void InitSubController(IntPtr L) { if (subCtrlList == null || subCtrlList.Count == 0) { return; } int oldTop = LuaDLL.lua_gettop(L); Lua.state.Push(luaController); for (int i = 0; i < subCtrlList.Count; ++i) { LuaDLL.lua_pushstring(L, subCtrlList[i].name); if (subCtrlList[i].next) { UILuaExporter p = subCtrlList[i]; LuaDLL.lua_newtable(L); int n = 1; while (p != null) { p.InitLuaController(L); Lua.state.Push(p.luaController); LuaDLL.lua_rawseti(L, -2, n++); p = p.next; } } else { subCtrlList[i].InitLuaController(L); Lua.state.Push(subCtrlList[i].luaController); } LuaDLL.lua_settable(L, -3); } LuaDLL.lua_settop(L, oldTop); }
static void OnPrefabInstanceUpdate(GameObject instance) { GameObject prefab = PrefabUtility.GetPrefabParent(instance) as GameObject; LuaBehaviour lb = prefab.GetComponent <LuaBehaviour>(); if (lb == null) { return; } UILuaExporter expt = prefab.GetComponent <UILuaExporter>(); if (expt == null) { return; //expt = prefab.AddComponent<UILuaExporter>(); } lb.exporter = expt; expt.subCtrlList = null; FillLuaExporter(prefab, expt, true); EditorUtility.SetDirty(prefab); }