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

Function ReleaseResource

engine/gamesys/src/gamesys/scripts/script_resource.cpp:1242–1255  ·  view source on GitHub ↗

release a resource * Release a resource. * * [icon:attention] This is a potentially dangerous operation, releasing resources currently being used can cause unexpected behaviour. * * @name resource.release * * @param path [type:hash|string] The path to the resource. * */

Source from the content-addressed store, hash-verified

1240 *
1241 */
1242static int ReleaseResource(lua_State* L)
1243{
1244 DM_LUA_STACK_CHECK(L, 0);
1245 dmhash_t path_hash = dmScript::CheckHashOrString(L, 1);
1246 HResourceDescriptor rd = dmResource::FindByHash(g_ResourceModule.m_Factory, path_hash);
1247 if (!rd) {
1248 return luaL_error(L, "Could not release resource: %s", dmHashReverseSafe64(path_hash));
1249 }
1250 dmGameObject::HInstance sender_instance = dmScript::CheckGOInstance(L);
1251 dmGameObject::HCollection collection = dmGameObject::GetCollection(sender_instance);
1252 dmGameObject::RemoveDynamicResourceHash(collection, path_hash);
1253 dmResource::Release(g_ResourceModule.m_Factory, dmResource::GetResource(rd));
1254 return 0;
1255}
1256
1257/*# set a texture
1258 * Sets the pixel data for a specific texture.

Callers

nothing calls this directly

Calls 9

CheckHashOrStringFunction · 0.85
FindByHashFunction · 0.85
luaL_errorFunction · 0.85
dmHashReverseSafe64Function · 0.85
CheckGOInstanceFunction · 0.85
GetCollectionFunction · 0.85
ReleaseFunction · 0.50
GetResourceFunction · 0.50

Tested by

no test coverage detected