A reusable object hierarchy stored as a resource. Can be instantiated through script or brought into the scene through Lens Studio. For more information, see the Prefabs guide.

// Instantiate a prefab under a parent scene object
// @input Asset.ObjectPrefab prefab
// @input SceneObject parentObject
var newObject = script.prefab.instantiate(script.parentObject);
print("Prefab Instantiated: " + newObject.name);
interface ObjectPrefab {
    name: string;
    uniqueIdentifier: string;
    getTypeName(): string;
    instantiate(parent: SceneObject): SceneObject;
    instantiateAsync(parent: SceneObject, onSuccess: ((sceneObject: SceneObject) => void), onFailure: ((error: string) => void), onProgress: ((progress: number) => void)): void;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

name: string

The name of the Asset in Lens Studio.

uniqueIdentifier: string

Methods

  • Returns the name of this object's type.

    Returns string

  • 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

    Returns SceneObject

  • Parameters

    • parent: SceneObject
    • onSuccess: ((sceneObject: SceneObject) => void)
        • (sceneObject): void
        • Parameters

          Returns void

    • onFailure: ((error: string) => void)
        • (error): void
        • Parameters

          • error: string

          Returns void

    • onProgress: ((progress: number) => void)
        • (progress): void
        • Parameters

          • progress: number

          Returns void

    Returns void

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean