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,26 @@
# GameObject::DetachFromParent
公开方法,详见头文件声明
把当前对象从父节点分离,并保持世界空间变换
```cpp
void DetachFromParent();
```
该方法声明于 `XCEngine/Components/GameObject.h`,当前页面用于固定 `GameObject` 类目录下的方法级 canonical 路径。
## 行为说明
**参数:** 无。
当前实现很直接:
**返回:** `void` - 无返回值。
- 如果当前没有父节点,直接返回
- 否则调用 `SetParent(nullptr, true)`
**示例:**
因此它的真实语义是:
```cpp
#include <XCEngine/Components/GameObject.h>
void Example() {
XCEngine::Components::GameObject object;
// 根据上下文补齐参数后调用 GameObject::DetachFromParent(...)。
(void)object;
}
```
- 把对象提升为根对象,或在无场景时变成无父独立对象
- 保持当前世界空间位置/旋转/缩放
- 同步更新场景根列表与层级激活态传播
## 相关文档
- [返回类总览](GameObject.md)
- [返回模块目录](../Components.md)
- [SetParent](SetParent.md)
- [GetParent](GetParent.md)
- [DetachChildren](DetachChildren.md)