コード例 #1
0
ファイル: Register.cs プロジェクト: iuvei/hzmj_client
    public static void RegisterClass(string className)
    {
        //Debug.Log("className: " + className);
        Type type = GetGameClassType(className);

        LuaInstance.instance.Get().Pop(1);
        AddFuncInfo(type, className);
        LuaClass lua_class = LuaInstance.instance.RegisterLuaClass(type);

        if (lua_class.is_register == false)
        {
            FuncInfo[] funcInfos;
            if (LuaClassList.classes.TryGetValue(type, out funcInfos))
            {
                for (int j = 0; j < funcInfos.Length; j++)
                {
                    if (funcInfos[j].IsStatic)
                    {
                        lua_class.RegisterStaticFunction(funcInfos[j]);
                    }
                    else
                    {
                        lua_class.RegisterFunction(funcInfos[j]);
                    }
                }
            }
            lua_class.EndRegisterClass();
        }
    }
コード例 #2
0
ファイル: LuaInstance_util.cs プロジェクト: iuvei/hzmj_client
    LuaInstance()
    {
        lua_ = LuaAPI.NewState(IntPtr.Zero);
        lua_.L_OpenLibs();
        LuaClassList.Init();

        for (int i = 0; i < 10; i++)
        {
            params_[i] = new object[i];
        }

        //Register Debug.Log
        Type     debugClassType = typeof(Debug);
        LuaClass lua_class      = RegisterLuaClass(debugClassType);

        FuncInfo[] funcInfos;
        if (LuaClassList.classes.TryGetValue(debugClassType, out funcInfos))
        {
            for (int j = 0; j < funcInfos.Length; j++)
            {
                lua_class.RegisterStaticFunction(funcInfos[j]);
            }
        }
        lua_class.EndRegisterClass();
    }
コード例 #3
0
ファイル: LuaBehaviour.cs プロジェクト: iuvei/hzmj_client
    public void RegComp(UnityEngine.Object regObj, Type type, string name, bool isArray = false)
    {
        LuaState lua_ = LuaInstance.instance.Get();

        Register.AddFuncInfo(type);
        LuaClass lua_class = LuaInstance.instance.RegisterLuaClass(type);

        FuncInfo[] funcInfos;
        if (lua_class.is_register == false)
        {
            if (LuaClassList.classes.TryGetValue(type, out funcInfos))
            {
                for (int j = 0; j < funcInfos.Length; j++)
                {
                    if (funcInfos[j].IsStatic)
                    {
                        lua_class.RegisterStaticFunction(funcInfos[j]);
                    }
                    else
                    {
                        lua_class.RegisterFunction(funcInfos[j]);
                    }
                }
            }

            lua_class.EndRegisterClass();
        }
        // register other CSharp object to lua object field
        if (isArray)
        {
            LuaInstance.instance.RegisterGameObject(regObj, Object_ref);
        }
        else
        {
            lua_.RawGetI(LuaAPI.LUA_REGISTRYINDEX, Object_ref);
            LuaInstance.instance.RegisterGameObject(regObj, name);
        }
    }
コード例 #4
0
    public void RegisterType(Type type)
    {
        LuaClass lua_class = RegisterLuaClass(type);

        if (lua_class.is_register == false)
        {
            FuncInfo[] funcInfos;
            if (LuaClassList.classes.TryGetValue(type, out funcInfos))
            {
                for (int j = 0; j < funcInfos.Length; j++)
                {
                    if (funcInfos[j].IsStatic)
                    {
                        lua_class.RegisterStaticFunction(funcInfos[j]);
                    }
                    else
                    {
                        lua_class.RegisterFunction(funcInfos[j]);
                    }
                }
            }
            lua_class.EndRegisterClass();
        }
    }