• 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<String, 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

@:native("get_status")staticgetStatus(?url:Null<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

@:has_untypedstaticinlineload(?url:Null<HashOrStringOrUrl>, ?completeFunction:(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

completeFunction

function to call when resources are loaded.

@:native("set_prototype")staticsetPrototype(url:HashOrStringOrUrl, ?prototype:String):Void

  • Changes the prototype for the collection factory. This allows the developer to load and spawn an arbitrary .collectionc/.goc file, further simplifying using dynamic content. The .collectionc/.goc files still need to be part of the resource archive.

We’ve added a “Dynamic Prototype” checkbox to the factories. The prototype can only be overridden when this is checked. If set, then the collection component count cannot be optimized, and the owning collection will use the default component counts from game.project.

Setting the prototype to null will revert back to the original prototype.

Parameters:

url

the collection factory component

prototype

the path to the new prototype, or null

staticunload(?url:Null<HashOrStringOrUrl>):Void

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