ObjectPrefab
ClassRepresents reusable SceneObject hierarchy stored as a resource.
- Available on all platforms
Index
Properties
Methods
Remarks
Can be instantiated through script or brought into the scene by dragging from Asset Browser to Scene Hierarchy panel.
Example
// Instantiate a prefab under a parent {@link SceneObject}
// @input Asset.ObjectPrefab prefab
// @input SceneObject parentObject
var newObject = script.prefab.instantiate(script.parentObject);
print("Prefab Instantiated: " + newObject.name);
Extends
Properties
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
createFromSceneObject()
staticcreateFromSceneObject(sceneObject):ObjectPrefab
Creates an ObjectPrefab based on the given SceneObject and it's children. That ObjectPrefab can then be instantiated. /
Parameters
| Parameter | Type |
|---|---|
sceneObject | SceneObject |
Returns
ObjectPrefab
Since
Lens Scripting Version 344
getTypeName()
staticgetTypeName():TypeName<ObjectPrefab>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<ObjectPrefab>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
instantiate()
instantiate(
parent?):SceneObject
Creates and returns a new instance of this object hierarchy underneath the specified parent object. If parent is null, the object will be created with no parent.
Parameters
| Parameter | Type |
|---|---|
parent? | SceneObject |
Returns
instantiateAsync()
instantiateAsync(
parent,onSuccess,onFailure,onProgress):void
Instantiate a prefab asynchronously.
Parameters
| Parameter | Type |
|---|---|
parent | SceneObject |
onSuccess | (sceneObject) => void |
onFailure | (error) => void |
onProgress | (progress) => void |
Returns
void
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
See also
Prefabs guide.