docs: expand gameobject helper docs
This commit is contained in:
@@ -1,30 +1,29 @@
|
||||
# GameObject::Start
|
||||
|
||||
公开方法,详见头文件声明。
|
||||
向当前对象及其子树分发一次性的 `Start()` 阶段。
|
||||
|
||||
```cpp
|
||||
void Start();
|
||||
```
|
||||
|
||||
该方法声明于 `XCEngine/Components/GameObject.h`,当前页面用于固定 `GameObject` 类目录下的方法级 canonical 路径。
|
||||
## 行为说明
|
||||
|
||||
**参数:** 无。
|
||||
当前实现分两步:
|
||||
|
||||
**返回:** `void` - 无返回值。
|
||||
1. 若对象不处于 `active in hierarchy`,直接返回
|
||||
2. 若对象尚未 `m_started`
|
||||
- 对所有已启用普通组件调用 `Start()`
|
||||
- 把 `m_started` 置为 `true`
|
||||
3. 无论当前对象是否第一次启动,都会继续递归对子对象调用 `Start()`
|
||||
|
||||
**示例:**
|
||||
## 重要边界
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Components/GameObject.h>
|
||||
|
||||
void Example() {
|
||||
XCEngine::Components::GameObject object;
|
||||
// 根据上下文补齐参数后调用 GameObject::Start(...)。
|
||||
(void)object;
|
||||
}
|
||||
```
|
||||
- 每个对象自己的 `Start()` 只会自动执行一次
|
||||
- 子对象也通过这个递归链进入 `Start()`
|
||||
- 运行时后加的组件不会因为对象已启动过而自动补发 `Start()`
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [返回类总览](GameObject.md)
|
||||
- [返回模块目录](../Components.md)
|
||||
- [Awake](Awake.md)
|
||||
- [Update](Update.md)
|
||||
- [IsActiveInHierarchy](IsActiveInHierarchy.md)
|
||||
|
||||
Reference in New Issue
Block a user