コード例 #1
0
        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));
        }
コード例 #2
0
 static public Delegate Create(LuaFunction func)
 {
     if (func != null)
     {
         LuaState luaState = func.GetLuaState();
         // 是否有保存
         LuaDelegate luaDelegate = luaState.GetLuaDelegate(func);
         if (luaDelegate != null)
         {
             return(Delegate.CreateDelegate(typeof(T), luaDelegate, luaDelegate.method));
         }
         Delegate d = _Create(func, null, false);
         luaDelegate        = d.Target as LuaDelegate;
         luaDelegate.method = d.Method;
         luaState.AddLuaDelegate(luaDelegate, func);
         return(d);
     }
     return(_Create(null, null, false));
 }