docs: expand gameobject helper docs
This commit is contained in:
@@ -1,30 +1,34 @@
|
||||
# GameObject::GetChildren
|
||||
|
||||
获取相关状态或对象。
|
||||
返回当前对象全部直接子对象的指针列表。
|
||||
|
||||
```cpp
|
||||
std::vector<GameObject*> GetChildren() const;
|
||||
```
|
||||
|
||||
该方法声明于 `XCEngine/Components/GameObject.h`,当前页面用于固定 `GameObject` 类目录下的方法级 canonical 路径。
|
||||
## 行为说明
|
||||
|
||||
**参数:** 无。
|
||||
当前实现直接返回 `m_children` 的一份拷贝。
|
||||
|
||||
**返回:** `std::vector<GameObject*>` - 返回值语义详见头文件声明。
|
||||
这意味着:
|
||||
|
||||
**示例:**
|
||||
- 结果里的每一项都是直接子对象指针
|
||||
- 返回的是容器副本,不是对内部数组的可写引用
|
||||
- 修改返回的 `std::vector` 本身,不会改变对象真实层级
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Components/GameObject.h>
|
||||
## 顺序语义
|
||||
|
||||
void Example() {
|
||||
XCEngine::Components::GameObject object;
|
||||
// 根据上下文补齐参数后调用 GameObject::GetChildren(...)。
|
||||
(void)object;
|
||||
}
|
||||
```
|
||||
返回顺序与当前内部 `m_children` 顺序一致,也就是:
|
||||
|
||||
- `SetParent()` 加入子对象时建立的顺序
|
||||
- 后续层级重排后形成的当前顺序
|
||||
|
||||
## 返回值
|
||||
|
||||
- `std::vector<GameObject*>` - 当前全部直接子对象。
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [返回类总览](GameObject.md)
|
||||
- [返回模块目录](../Components.md)
|
||||
- [GetChild](GetChild.md)
|
||||
- [GetChildCount](GetChildCount.md)
|
||||
- [DetachChildren](DetachChildren.md)
|
||||
|
||||
Reference in New Issue
Block a user