docs: refactor Components API content
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# SetMaterialPath
|
||||
|
||||
**所属类型**: [MeshRendererComponent](MeshRendererComponent.md)
|
||||
|
||||
## 签名
|
||||
|
||||
```cpp
|
||||
void SetMaterialPath(size_t index, const std::string& materialPath);
|
||||
```
|
||||
|
||||
## 作用
|
||||
|
||||
为指定材质槽设置资源路径,并尝试通过 `ResourceManager` 加载对应材质。
|
||||
|
||||
## 当前实现行为
|
||||
|
||||
- 调用内部 `EnsureMaterialSlot(index)` 自动扩容槽位数组。
|
||||
- 先记录 `m_materialPaths[index] = materialPath`。
|
||||
- 若路径为空,则重置该槽位的材质 handle。
|
||||
- 若路径非空,则调用 `ResourceManager::Get().Load<Resources::Material>(...)` 尝试加载。
|
||||
- 即使加载失败,路径也会保留。
|
||||
|
||||
## 使用建议
|
||||
|
||||
这比直接设置 handle 更适合编辑器材质面板和序列化恢复路径,因为路径才是当前场景文件的主持久化数据。
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [MeshRendererComponent](MeshRendererComponent.md)
|
||||
- [GetMaterialPath](GetMaterialPath.md)
|
||||
- [Serialize](Serialize.md)
|
||||
- [Deserialize](Deserialize.md)
|
||||
Reference in New Issue
Block a user