Editor.Model.SceneObject
ClassA node in the scene hierarchy, holding components and child scene objects.
Index
Properties
Methods
- addChildAt
- addComponent
- addComponentAt
- applyToPrefab
- clearChildren
- clearComponents
- commonParent
- copy
- destroy
- getChildAt
- getChildrenCount
- getComponent
- getComponentAt
- getComponents
- getComponentsCount
- getDirectlyReferencedEntities
- getMeta
- getOwnedEntities
- getParent
- getPrefabInstanceRoot
- getTypeName
- indexOfChild
- indexOfComponent
- isOfType
- isSame
- moveChild
- moveComponent
- removeChild
- removeChildAt
- removeComponent
- removeComponentAt
- resetFromPrefab
- setChildAt
- setComponentAt
- setParent
- staticMeta
- topLevel
- unlinkFromPrefab
Example
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;
const rootObjects = scene.rootSceneObjects;
console.log(`Root scene objects: ${rootObjects.length}`);
for (const obj of rootObjects) {
console.log(`Object: "${obj.name}", enabled: ${obj.enabled}`);
console.log(` Children: ${obj.getChildrenCount()}`);
console.log(` Components: ${obj.getComponentsCount()}`);
console.log(` Has visuals: ${obj.hasVisuals}`);
const transform = obj.localTransform;
console.log(` Local position: ${transform.position}`);
console.log(` Local rotation: ${transform.rotation}`);
console.log(` Local scale: ${transform.scale}`);
const children = obj.children;
for (const child of children) {
console.log(` Child: "${child.name}"`);
}
const components = obj.components;
for (const comp of components) {
console.log(` Component type: ${comp.type}`);
}
}
if (rootObjects.length === 0) {
console.log('No root scene objects found in the scene.');
}
Extends
Properties
children
children:
SceneObject[]
A list of scene objects that is a child of this scene object.
components
components:
Component[]
A list of components that is a child of this scene object.
enabled
enabled:
boolean
Whether this scene object is enabled or disabled.
hasPrefabChanges
readonlyhasPrefabChanges:boolean
Whether this entity differs from its counterpart in the prefab or was added to the prefab instance. Always false outside prefab instances.
Inherited from
hasVisuals
readonlyhasVisuals:boolean
Whether this scene object contains any component which is of type Editor.Components.Visual.
id
readonlyid:Uuid
The unique id of the entity.
Inherited from
isPrefabInstanceRoot
readonlyisPrefabInstanceRoot:boolean
Whether this entity is the root of a prefab instance.
Inherited from
Prefabable.isPrefabInstanceRoot
isPrefabPrototypeRoot
readonlyisPrefabPrototypeRoot:boolean
Whether this object is the root object stored inside a prefab asset, rather than an instance in a scene.
layers
layers:
LayerSet
The layerSet this scene object is on.
localTransform
localTransform:
TransformEntity
The transform of this scene object relative to its parent.
meta
readonlymeta:Meta
Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.
Inherited from
name
name:
string
The name of the scene object.
topOwner
readonlytopOwner:ObjectOwner
The root owner object at the top of this object's ownership chain.
type
readonlytype:string
The entity's type.
Inherited from
worldTransform
worldTransform:
WorldTransformAccessor
The transform of this scene object relative to the scene its in.
Methods
addChildAt()
addChildAt(
value,pos?):void
Add a scene object as a child of this object at a specified pos.
Parameters
| Parameter | Type |
|---|---|
value | SceneObject |
pos? | number |
Returns
void
addComponent()
addComponent<
K>(componentType):ComponentNameMap[K]
Add a new Editor.Components.Component by componentType to this object.
Type Parameters
| Type Parameter |
|---|
K extends keyof ComponentNameMap |
Parameters
| Parameter | Type |
|---|---|
componentType | K |
Returns
ComponentNameMap[K]
addComponentAt()
addComponentAt(
value,pos?):void
Add the component value at the specified pos.
Parameters
| Parameter | Type |
|---|---|
value | Component |
pos? | number |
Returns
void
applyToPrefab()
applyToPrefab():
void
Apply the changes in this object's prefab instance to the prefab asset, which propagates them to its other instances. Logs a warning and does nothing if the object is not in an editable prefab instance.
Returns
void
clearChildren()
clearChildren():
void
Remove all children from this object.
Returns
void
clearComponents()
clearComponents():
void
Remove all components from this scene object.
Returns
void
commonParent()
staticcommonParent(sceneObjects):SceneObject
Returns the nearest common ancestor shared by a set of scene objects.
Parameters
| Parameter | Type |
|---|---|
sceneObjects | SceneObject[] |
Returns
SceneObject
copy()
copy():
SceneObject
Returns a deep copy of this scene object, including its children and components.
Returns
SceneObject
destroy()
destroy():
void
Destroy this scene object. All references to it becomes invalid.
Returns
void
getChildAt()
getChildAt(
pos):SceneObject
Get a specific object at the specified pos.
Parameters
| Parameter | Type |
|---|---|
pos | number |
Returns
SceneObject
getChildrenCount()
getChildrenCount():
number
Get the number of children on this object.
Returns
number
getComponent()
getComponent<
K>(componentType):ComponentNameMap[K]
Get the first component of componentType.
Type Parameters
| Type Parameter |
|---|
K extends keyof ComponentNameMap |
Parameters
| Parameter | Type |
|---|---|
componentType | K |
Returns
ComponentNameMap[K]
getComponentAt()
getComponentAt(
pos):Component
Get the component at the specified pos.
Parameters
| Parameter | Type |
|---|---|
pos | number |
Returns
getComponents()
getComponents<
K>(componentType):ComponentNameMap[K][]
Get all the components of componentType on this object.
Type Parameters
| Type Parameter |
|---|
K extends keyof ComponentNameMap |
Parameters
| Parameter | Type |
|---|---|
componentType | K |
Returns
ComponentNameMap[K][]
getComponentsCount()
getComponentsCount():
number
Get the number of components on this object.
Returns
number
getDirectlyReferencedEntities()
getDirectlyReferencedEntities():
Entity[]
A list of entities which this entity has a reference to.
Returns
Entity[]
Inherited from
Prefabable.getDirectlyReferencedEntities
getMeta()
staticgetMeta():Meta
Returns metadata about this type.
Returns
Inherited from
getOwnedEntities()
getOwnedEntities():
Entity[]
A list of entities which has a reference to this entity.
Returns
Entity[]
Inherited from
getParent()
getParent():
SceneObject
Get the parent of this scene object.
Returns
SceneObject
getPrefabInstanceRoot()
getPrefabInstanceRoot():
Prefabable
Returns the nearest prefab instance root that contains this entity, starting with the entity itself, or null if it is not part of a prefab instance.
Returns
Inherited from
Prefabable.getPrefabInstanceRoot
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
indexOfChild()
indexOfChild(
value):number
Get the position of a specific object, if the object is a child of this object.
Parameters
| Parameter | Type |
|---|---|
value | SceneObject |
Returns
number
indexOfComponent()
indexOfComponent(
value):number
Get the position of a specific component value on this object.
Parameters
| Parameter | Type |
|---|---|
value | Component |
Returns
number
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
moveChild()
moveChild(
child,destination):void
Move child in the order of children on this object.
Parameters
| Parameter | Type |
|---|---|
child | SceneObject |
destination | number |
Returns
void
moveComponent()
moveComponent(
origin,destination):void
Move the component value to a specified pos.
Parameters
| Parameter | Type |
|---|---|
origin | number |
destination | number |
Returns
void
removeChild()
removeChild(
child):void
Remove a child from this from this scene object.
Parameters
| Parameter | Type |
|---|---|
child | SceneObject |
Returns
void
removeChildAt()
removeChildAt(
pos):void
Remove a child at the specified pos.
Parameters
| Parameter | Type |
|---|---|
pos | number |
Returns
void
removeComponent()
removeComponent(
componentType):boolean
Remove the first component of componentType from this object.
Parameters
| Parameter | Type |
|---|---|
componentType | string |
Returns
boolean
removeComponentAt()
removeComponentAt(
pos):void
Remove the components at the specified pos.
Parameters
| Parameter | Type |
|---|---|
pos | number |
Returns
void
resetFromPrefab()
resetFromPrefab():
void
Discard the changes in this object's prefab instance so it matches the prefab asset again. Logs a warning and does nothing if the object is not in an editable prefab instance.
Returns
void
setChildAt()
setChildAt(
pos,value):void
Set the child scene object value to be at the specified pos.
Parameters
| Parameter | Type |
|---|---|
pos | number |
value | SceneObject |
Returns
void
setComponentAt()
setComponentAt(
pos,value):void
Set the component value to be at the specified pos.
Parameters
| Parameter | Type |
|---|---|
pos | number |
value | Component |
Returns
void
setParent()
setParent(
newParent,position?):void
Set the parent of this scene object.
Parameters
| Parameter | Type |
|---|---|
newParent | SceneObject |
position? | number |
Returns
void
staticMeta()
staticstaticMeta():Meta
Returns the static metadata descriptor for the SceneObject type.
Returns
topLevel()
statictopLevel(sceneObjects):SceneObject[]
Returns the topmost ancestor of this object in the scene hierarchy.
Parameters
| Parameter | Type |
|---|---|
sceneObjects | SceneObject[] |
Returns
SceneObject[]
unlinkFromPrefab()
unlinkFromPrefab():
void
Disconnect this prefab instance root from its prefab asset so it becomes a regular scene object. Logs a warning and does nothing if the object is not a prefab instance root that can be unlinked.
Returns
void