Functions for controlling collection factory components which are used to dynamically spawn collections into the runtime.

Static methods

staticcreate(url:HashOrStringOrUrl, ?position:Vector3, ?rotation:Quaternion, ?properties:Table<Hash, Table<Hash, GoProperty>>, ?scale:Float):Table<Hash, Hash>

Spawn a new instance of a collection into the existing collection.

The URL identifies the collectionfactory component that should do the spawning.

Spawning is instant, but spawned game objects get their first update calls the following frame. The supplied parameters for position, rotation and scale will be applied to the whole collection when spawned.

Script properties in the created game objects can be overridden through a properties-parameter table. The table should contain game object ids (hash) as keys and property tables as values to be used when initiating each spawned game object.

See go.property for more information on script properties.

The function returns a table that contains a key for each game object id (hash), as addressed if the collection file was top level, and the corresponding spawned instance id (hash) as value with a unique path prefix added to each instance.

Calling Collectionfactory.create create on a collection factory that is marked as dynamic without having loaded resources using Collectionfactory.load will synchronously load and create resources which may affect application performance.

Parameters:

url

the collection factory component to be used

position

position to assign to the newly spawned collection

rotation

rotation to assign to the newly spawned collection

properties

table of script properties to propagate to any new game object instances (table)

scale

uniform scaling to apply to the newly spawned collection (must be greater than 0)

Returns:

a table mapping the id:s from the collection to the new instance id:s

staticget_status(?url:HashOrStringOrUrl):CollectionfactoryStatus

Get collection factory status.

This returns status of the collection factory.

Calling this function when the factory is not marked as dynamic loading always returns CollectionfactoryStatus.STATUS_LOADED.

Parameters:

url

the collection factory component to get status from

Returns:

status of the collection factory component

staticload<T>(?url:HashOrStringOrUrl, ?complete_function:(self:T, url:Url, result:Bool) ‑> Void):Void

Load resources of a collection factory prototype.

Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or Collectionfactory.unload is called.

Calling this function when the factory is not marked as dynamic loading does nothing.

Parameters:

url

the collection factory component to load

complete_function

function to call when resources are loaded.

staticunload(?url:HashOrStringOrUrl):Void

Unload resources previously loaded using Collectionfactory.load.

This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed.

Calling this function when the factory is not marked as dynamic loading does nothing.

Parameters:

url

the collection factory component to unload