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(); } }
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); } }
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(); } }