static int SetLuaTable(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); KSFramework.UILuaOutlet obj = (KSFramework.UILuaOutlet)ToLua.CheckObject(L, 1, typeof(KSFramework.UILuaOutlet)); obj.SetLuaTable(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int set_OutletInfos(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); KSFramework.UILuaOutlet obj = (KSFramework.UILuaOutlet)o; System.Collections.Generic.List <KSFramework.UILuaOutlet.OutletInfo> arg0 = (System.Collections.Generic.List <KSFramework.UILuaOutlet.OutletInfo>)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.List <KSFramework.UILuaOutlet.OutletInfo>)); obj.OutletInfos = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OutletInfos on a nil value" : e.Message)); } }
static int get_m_TargetLuaTable(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); KSFramework.UILuaOutlet obj = (KSFramework.UILuaOutlet)o; LuaInterface.LuaTable ret = obj.m_TargetLuaTable; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_TargetLuaTable on a nil value" : e.Message)); } }
static int get_OutletInfos(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); KSFramework.UILuaOutlet obj = (KSFramework.UILuaOutlet)o; System.Collections.Generic.List <KSFramework.UILuaOutlet.OutletInfo> ret = obj.OutletInfos; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index OutletInfos on a nil value" : e.Message)); } }
static int set_m_TargetLuaTable(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); KSFramework.UILuaOutlet obj = (KSFramework.UILuaOutlet)o; LuaTable arg0 = ToLua.CheckLuaTable(L, 2); obj.m_TargetLuaTable = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_TargetLuaTable on a nil value" : e.Message)); } }
public void SetOutlet(LuaTable _luaTable) { if (_luaTable != null) { Action <UILuaOutlet> fun = delegate(UILuaOutlet outlet) { for (var i = 0; i < outlet.OutletInfos.Count; i++) { var outletInfo = outlet.OutletInfos[i]; var gameObj = outletInfo.Object as GameObject; if (gameObj == null || outletInfo.ComponentType == typeof(UnityEngine.GameObject).FullName) { _luaTable.Set <string, UnityEngine.Object>(outletInfo.Name, outletInfo.Object); continue; } if (outletInfo.ComponentType == typeof(UnityEngine.Transform).FullName) { _luaTable.Set <string, Component>(outletInfo.Name, gameObj.transform); } else { var comp = gameObj.GetComponent(outletInfo.ComponentType); //UnityEngine.xxx,非UnityEngine.UI.xxx,只能通过typof获取。 if (comp == null && outletInfo.ComponentType.StartsWith("UnityEngine")) { //UnityEngine.xxx下的使用typeof获取 var comNames = outletInfo.ComponentType.Split('.'); if (!comNames[1].StartsWith("UI")) { var components = gameObj.GetComponents <Component>(); for (var c = 0; c < components.Length; c++) { var typeName = components[c].GetType().FullName; if (typeName == outletInfo.ComponentType) { comp = components[c]; break; } } } } if (comp == null) { var fmt = "Missing Component `{0}` at object `{1}` which named `{2}`"; Debug.LogError(string.Format(fmt, outletInfo.ComponentType, gameObj, outletInfo.Name)); } else { _luaTable.Set <string, Component>(outletInfo.Name, comp); } } } }; UILuaOutletCollection outletCollection = this.GetComponent <UILuaOutletCollection>(); if (outletCollection) { if (outletCollection.UILuaOutlets != null && outletCollection.UILuaOutlets.Length > 0) { for (int i = 0; i < outletCollection.UILuaOutlets.Length; i++) { UILuaOutlet item = outletCollection.UILuaOutlets[i]; if (item != null) { fun(item); } } } } else { var outlet = this.GetComponent <UILuaOutlet>(); if (outlet != null) { fun(outlet); } } } }