public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self) { DelegateCreate Create = null; if (!dict.TryGetValue(t, out Create)) { throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t))); } if (func != null) { LuaState state = func.GetLuaState(); LuaDelegate target = state.GetLuaDelegate(func, self); if (target != null) { return(Delegate.CreateDelegate(t, target, target.method)); } else { Delegate d = Create(func, self, true); target = d.Target as LuaDelegate; state.AddLuaDelegate(target, func, self); return(d); } } return(Create(null, null, true)); }
static public Delegate Create(LuaFunction func, LuaTable self) { #if UNITY_EDITOR if (_Create == null) { throw new LuaException(string.Format("Delegate {0} not register", TypeTraits <T> .GetTypeName())); } #endif if (func != null) { LuaState state = func.GetLuaState(); LuaDelegate target = state.GetLuaDelegate(func, self); if (target != null) { return(Delegate.CreateDelegate(typeof(T), target, target.method)); } else { Delegate d = _Create(func, self, true); target = d.Target as LuaDelegate; state.AddLuaDelegate(target, func, self); return(d); } } return(_Create(null, null, true)); }
public static Delegate CreateDelegate(Type t, LuaFunction func = null) { if (!dict.TryGetValue(t, out var create)) { throw new LuaException($"Delegate {LuaMisc.GetTypeName(t)} not register"); } if (func == null) { return(create(null, null, false)); } LuaState state = func.GetLuaState(); LuaDelegate target = state.GetLuaDelegate(func); if (target != null) { return(Delegate.CreateDelegate(t, target, target.method)); } else { Delegate d = create(func, null, false); target = d.Target as LuaDelegate; state.AddLuaDelegate(target, func); return(d); } }
public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self) { DelegateFactory.DelegateValue delegateValue = null; if (!DelegateFactory.dict.TryGetValue(t, out delegateValue)) { throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)), null, 1); } if (!(func != null)) { return(delegateValue(func, self, true)); } LuaState luaState = func.GetLuaState(); LuaDelegate luaDelegate = luaState.GetLuaDelegate(func, self); if (luaDelegate != null) { return(Delegate.CreateDelegate(t, luaDelegate, luaDelegate.method)); } Delegate @delegate = delegateValue(func, self, true); luaDelegate = (@delegate.Target as LuaDelegate); luaState.AddLuaDelegate(luaDelegate, func, self); return(@delegate); }