Create a new AssetReference instance.
The name of the property that the asset is stored under, passed into callbacks to enable updating.
The parent object that contains the asset reference, passed into callbacks to enable updating. Currently an asset, but could be component or other.
The asset registry that stores all assets.
A set of functions called when the asset state changes: load, add, remove.
Optionaladd?: anyThe function called when the asset is added to the registry add(propertyName, parent, asset).
Optionalload?: anyThe function called when the asset loads load(propertyName, parent, asset).
Optionalremove?: anyThe function called when the asset is remove from the registry remove(propertyName, parent, asset).
Optionalunload?: anyThe function called when the asset is unloaded unload(propertyName, parent, asset).
Optionalscope: any
The scope to call the callbacks in.
Gets the asset id which this references.
Sets the asset id which this references. One of either id or url must be set to initialize an asset reference.
Gets the asset url which this references.
Sets the asset url which this references. One of either id or url must be called to initialize an asset reference.
An AssetReference follows a single asset slot on behalf of its owner, such as the texture property of a component, and calls back when that asset is added to the registry, loads or is removed. Point it at an asset by setting id or url. The asset does not need to exist yet: the
addcallback fires when an asset with that id or URL is later registered. Theunloadcallback is delivered only for a reference by id.Example