resolve
Retrieves an object by its ID and returns a reference to the corresponding object manager.
This method is used to retrieve an object that has already been created, but for which you don't have a reference to the ObjectManager
instance. This can be useful, for example, when the object was created by another script.
Syntax
engine.objects.resolveObject(object);
Parameters
Name | Type | Description |
---|---|---|
id | string | The ID of the object to retrieve |
forceUpdate? | boolean | Whether or not to force the object to update its data (optional) |
Returns
Promise<ObjectManager>
- A promise that resolves to the reference to theObjectManager
instance for the specified object, ornull
if the object is not found.
Example
script1.js
const box = engine.objects.create('box', {
id: 'my-box'
})
...
script2.js
const box = await engine.objects.resolve('my-box');
...
Available on: Client