BBMOD_ResourceManager

A constructor defined in BBMOD_ResourceManager.gml

Implements BBMOD_IDestructible

new BBMOD_ResourceManager()

Description

Using this struct you can easily load, retrieve and free from memory any BBMOD resources.

Properties

Name Description
LoadMaterials If true then BBMOD_ResourceManager.load automatically loads model materials when BBMAT files are found. Default value is true.
Loading Number of resources that are currently loading.

Methods

Name Description
add Adds a resource to the resource manager.
async_image_loaded_update Must be executed in the "Async - Image Loaded" event!
async_save_load_update Must be executed in the "Async - Save/Load" event!
clear Destroys all non-persistent resources.
destroy Frees memory used by the struct.
free Frees a reference to the resource. When there are no other no other references, the resource is destroyed.
get Retrieves a reference to a resource.
get_or_add Retrieves a reference to a resource. If the resource does not exist yet, then it is added.
has Checks if the resource manager has a resource.
load Asynchronnously loads a resource from a file or retrieves a reference to it, if it is already loaded.

Example

Create a resource manager in OMain:

/// @desc Create event
resourceManager = new BBMOD_ResourceManager();

/// @desc Clean Up event
resourceManager = resourceManager.destroy();

/// @desc Async - Image Loaded event
resourceManager.async_image_loaded_update(async_load);

/// @desc Async - Save/Load event
resourceManager.async_save_load_update(async_load);

Use the resource manager in another object to load its model or just retrieve a reference to it, if it is already loaded.

/// @desc Create event
model = OMain.resourceManager.load("Data/Model.bbmod");

/// @desc Clean Up event
// Free the reference. This is not necessary if you do not want to unload
// the model when all instances are destroyed. It will always be unloaded
// when the resource manager is destroyed.
model.free();

/// @desc Draw event
matrix_set(matrix_world, matrix_build(x, y, z, 0, 0, 0, 1, 1, 1));
model.render();

See also

BBMOD_Resource

Do you find this page helpful?

Copyright © 2024, BlueBurn. Built on April 26, 2024 using GMDoc.