Files
XCEngine/docs/api/resources/mesh-loader/methods/can-load.md

37 lines
963 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MeshLoader::CanLoad
## 方法签名
```cpp
bool CanLoad(const Containers::String& path) const override;
```
## 详细描述
检查给定路径的文件是否可以被该加载器加载。方法通过提取文件扩展名并转换为小写后进行匹配判断。支持的文件格式包括fbx、obj、gltf、glb、dae、stl。
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| path | `const Containers::String&` | 文件路径 |
## 返回值
`bool` - 如果文件扩展名在支持列表中返回 `true`,否则返回 `false`
## 示例
```cpp
#include "Resources/MeshLoader.h"
using namespace XCEngine::Resources;
MeshLoader loader;
bool canLoadFbx = loader.CanLoad("assets/models/player.fbx"); // true
bool canLoadObj = loader.CanLoad("assets/models/cube.obj"); // true
bool canLoadPng = loader.CanLoad("assets/textures/wood.png"); // false
bool canLoadUnknown = loader.CanLoad("assets/data/model.xyz"); // false
```