A function defined in BBMOD_ResourceManager.gml

get_or_add(_uniqueName, _onAdd)


Retrieves a reference to a resource. If the resource does not exist yet, then it is added.


Name Type Description
_uniqueName String The name of the resource. Must be unique!
_onAdd Function A function which creates the resource if it does not exist yet. Must take no arguments and must return the created resource.


Following code shows Create event of an object, where it assings its material using this method. When the first instance is created, it creates the material and adds it to the resource manager. When other instances are created, the material already exists and so they only get a reference to it.

/// @desc Create event
material = resourceManager.get_or_add("material", function () {
    var _mat = BBMOD_MATERIAL_DEFAULT.clone();
    _mat.BaseOpacity = sprite_get_texture(SprBaseOpacity, 0);
    return _mat;
Do you find this page helpful?

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