Skip to main content

LensStudio:HierarchyUtils.js.findOrCreateChildWithName

Function

Finds or creates a child scene object with the specified name under the given root object.

findOrCreateChildWithName(rootObject, name, scene): SceneObject

Finds or creates a child scene object with the specified name under the given root object. It only searches the immediate children of the root object. If a child object with the specified name already exists, it is returned. Otherwise, a new scene object is created, added to the scene, and assigned the specified name.

Parameters

ParameterTypeDescription
rootObjectSceneObjectThe root object under which to search for or create the child object.
namestringThe name of the child object to find or create. Only exact matches are considered.
sceneSceneThe scene in which to add the new scene object if it needs to be created.

Returns

SceneObject

The found or created child scene object.