Skip to main content

Component

TypeNameInterface Description
Variablesenabled: booleanFunction: Indicates whether the component is enabled. If the component is disabled, it may not be updated or rendered.
FunctionsgetSceneObject(): SceneObjectFunction: Get the SceneObject object to which this component belongs.

Return Value: Returns a SceneObject object that contains the component.

FunctionsisInheritedEnabled(): booleanFunction: Check whether the component is enabled and whether its parent object is also enabled.

Return value: Returns true if both the component and its parent object are enabled; otherwise, returns false.

Examples

enabled: boolean

meshrenderer.enabled = false

getSceneObject() : SceneObject

let sceneObject = component.getSceneObject();

isInheritedEnabled(): boolean

let inheritedEnabled = component.isInheritedEnabled();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
private firstFrame = true;
onStart() {
}
onUpdate(deltaTime: number) {
if (this.firstFrame) {
this.firstFrame = false;
let child = this.getSceneObject().getChild('Cube');
let meshRenderer = child?.getComponent('MeshRenderer');
if(meshRenderer){
meshRenderer.enabled = false;
console.log("meshRenderer enabled:", meshRenderer.isInheritedEnabled());
console.log("sceneObject enabled:", meshRenderer.getSceneObject().enabled);
}
}
}
}
component example

DemoComponentAPI.zip

Copyright © 2025 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalCookies