SplitScript reference / UnityGameObject / child

UnityGameObject.child

Method

UnityGameObject.child(name: String) -> UnityGameObject!

Finds one exact direct child by name.

Prefer find when several hierarchy segments are already known.

Parameters

  • name: Exact name of the direct child to find.

Effects: reads process memory, requires an attached process

Runtime behavior: available while a process is attached, except in onDetach; synchronous

Examples

Resolve a direct child

whileAttached {
    let scene = unity.scenes.active() else return
    let world = scene.find("World") else return
    let player = world.child("Player") else return
    print(player.name() else "Unknown")
}