MCPcopy Create free account
hub / github.com/Tencent/UnLua / UClass_Load

Function UClass_Load

Plugins/UnLua/Source/UnLua/Private/BaseLib/LuaLib_Class.cpp:49–74  ·  view source on GitHub ↗

* Load a class. for example: UClass.Load("/Game/Core/Blueprints/AICharacter.AICharacter_C") */

Source from the content-addressed store, hash-verified

47 * Load a class. for example: UClass.Load("/Game/Core/Blueprints/AICharacter.AICharacter_C")
48 */
49int32 UClass_Load(lua_State* L)
50{
51 int32 NumParams = lua_gettop(L);
52 if (NumParams != 1)
53 return luaL_error(L, "invalid parameters");
54
55 const char* ClassPath = lua_tostring(L, 1);
56 if (!ClassPath)
57 return luaL_error(L, "invalid class name");
58
59 FString Name = UTF8_TO_TCHAR(ClassPath);
60
61#if UNLUA_LEGACY_BLUEPRINT_PATH
62 LeagcyAppendSuffix(Name);
63#endif
64
65 UClass* Class = LoadObject<UClass>(nullptr, *Name);
66 if (!Class)
67 return 0;
68
69 if (!UnLua::FLuaEnv::FindEnvChecked(L).GetClassRegistry()->Register(Class))
70 return 0;
71
72 UnLua::PushUObject(L, Class);
73 return 1;
74}
75
76/**
77 * Test whether this class is a child of another class

Callers

nothing calls this directly

Calls 5

lua_gettopFunction · 0.85
luaL_errorFunction · 0.85
LeagcyAppendSuffixFunction · 0.85
PushUObjectFunction · 0.85
RegisterMethod · 0.45

Tested by

no test coverage detected