MCPcopy Create free account
hub / github.com/defold/defold / FactoryComp_Unload

Function FactoryComp_Unload

engine/gamesys/src/gamesys/scripts/script_factory.cpp:116–130  ·  view source on GitHub ↗

Unload resources previously loaded using factory.load * * This decreases the reference count for each resource loaded with factory.load. If reference is zero, the resource is destroyed. * * Calling this function when the factory is not marked as dynamic loading does nothing. * * @name factory.unload * @param [url] [type:string|hash|url] the factory component to u

Source from the content-addressed store, hash-verified

114 * ```
115 */
116 static int FactoryComp_Unload(lua_State* L)
117 {
118 DM_LUA_STACK_CHECK(L, 0);
119
120 HFactoryWorld world;
121 HFactoryComponent component;
122 dmScript::GetComponentFromLua(L, 1, FACTORY_EXT, (dmGameObject::HComponentWorld*)&world, (dmGameObject::HComponent*)&component, 0);
123
124 bool success = dmGameSystem::CompFactoryUnload(world, component);
125 if (!success)
126 {
127 return DM_LUA_ERROR("Error unloading factory resources");
128 }
129 return 0;
130 }
131
132
133 /*# Load resources of a factory prototype.

Callers

nothing calls this directly

Calls 2

CompFactoryUnloadFunction · 0.85
GetComponentFromLuaFunction · 0.50

Tested by

no test coverage detected