The base class for all components. Components are attached to SceneObject and add various behaviors to it.

For example, in the default scene, the Camera Object is a scene object which contains the Camera component to render the scene from the point of view of that object. You can add a DeviceTracking component onto the object, so that the Transform of that object is modified based on the device's movement.

You can add a component to an object by selecting an object in the Scene Hierarchy panel, and pressing + Add Component in the Inspector panel; or through script:

const currentObject =  script.sceneObject;
const newImageComponent = currentObject.createComponent("Component.Image");

You can access components on an object directyly through script:

const currentObject =  script.sceneObject;
const firstImageOnObject = currentObject.getComponent("Component.Image");

or creating an input for it:

// @input Component.image passedInComponent
const imageComponent = script.passedInComponent;

Component classes can be a child of other classes. For example, you can get a ClothVisual and EyeColorVisual by asking for the parent MaterialMeshVisual.

// Get the first MaterialMeshVisual on the object
const someMaterialMeshVissual = currentObject.getComponent("Component.MaterialMeshVisual");

// Confirm the type of visual that is needed
if(someMaterialMeshVissual.isOfType("Component.ClothVisual")){
var mat = someMaterialMeshVissual.mainMaterial;
}

You can also write these scripts as TypeScript. Learn more in the TypeScript guide.

@component
export class somethingWithImage extends BaseScriptComponent {
@input
imageComponent: Component.Image;

onAwake() {
let imageComponent = this.imageComponent;
}
}

Hierarchy (View Summary, Expand)

Constructors

Properties

enabled: boolean

If disabled, the Component will stop enacting its behavior.

sceneObject: SceneObject

The scene object this component is on.

uniqueIdentifier: string

Methods

  • Destroys the component.

    Returns void

  • Returns the Transform this component is attached to.

    Returns Transform

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

    Parameters

    • type: string

    Returns boolean

MMNEPVFCICPMFPCPTTAAATR