28 lines
693 B
Markdown
28 lines
693 B
Markdown
# MeshRendererComponent::SetMaterial
|
|
|
|
设置单个材质槽。
|
|
|
|
```cpp
|
|
void SetMaterial(size_t index, const Resources::ResourceHandle<Resources::Material>& material);
|
|
void SetMaterial(size_t index, Resources::Material* material);
|
|
```
|
|
|
|
## 行为说明
|
|
|
|
当前实现会:
|
|
|
|
1. 通过 `EnsureMaterialSlot()` 保证数组至少扩容到 `index + 1`。
|
|
2. 写入 `m_materials[index]`。
|
|
3. 根据句柄中的资源路径同步更新 `m_materialPaths[index]`。
|
|
|
|
## 参数
|
|
|
|
- `index` - 材质槽索引。
|
|
- `material` - 要设置的材质句柄或裸指针。
|
|
|
|
## 相关文档
|
|
|
|
- [返回类型总览](MeshRendererComponent.md)
|
|
- [SetMaterials](SetMaterials.md)
|
|
- [ClearMaterials](ClearMaterials.md)
|