738 B
738 B
GameObject::GetChild
按索引返回当前对象的直接子对象。
GameObject* GetChild(size_t index) const;
行为说明
当前实现只访问 m_children:
- 若
index < m_children.size(),返回对应子对象指针 - 否则返回
nullptr
它不会递归搜索孙节点或更深层子树。
tests/Components/test_game_object.cpp 已验证:
- 有效索引会返回正确子对象
- 越界索引会返回
nullptr
参数
index- 直接子对象索引,基于当前m_children顺序。
返回值
GameObject*- 对应直接子对象;越界时返回nullptr。