docs: expand gameobject helper docs

This commit is contained in:
2026-04-03 16:11:48 +08:00
parent ee44e14960
commit 2c2e1fab1c
34 changed files with 597 additions and 603 deletions

View File

@@ -1,30 +1,22 @@
# GameObject::OnDestroy
公开方法,详见头文件声明
向当前对象的普通组件分发销毁通知
```cpp
void OnDestroy();
```
该方法声明于 `XCEngine/Components/GameObject.h`,当前页面用于固定 `GameObject` 类目录下的方法级 canonical 路径。
## 行为说明
**参数:**
当前实现会遍历 `m_components`,并对每个普通组件调用 `OnDestroy()`
**返回:** `void` - 无返回值。
需要注意:
**示例:**
```cpp
#include <XCEngine/Components/GameObject.h>
void Example() {
XCEngine::Components::GameObject object;
// 根据上下文补齐参数后调用 GameObject::OnDestroy(...)。
(void)object;
}
```
- 它不会递归销毁子对象;子对象销毁由 `Scene::DestroyGameObject()` 递归控制
- `TransformComponent` 不在 `m_components` 中,因此不会在这里收到 `OnDestroy()`
- 析构函数本身不会自动调用这个接口
## 相关文档
- [返回类总览](GameObject.md)
- [返回模块目录](../Components.md)
- [Destroy](Destroy.md)
- [Scene::DestroyGameObject](../../Scene/Scene/DestroyGameObject.md)