在unity 加载网页的模型文件资源(路径) https://remote.ruifbl.com/document/8608chanpin/room.fbx
时间: 2024-10-19 20:04:42 浏览: 55
在Unity中加载外部网络上的FBX模型文件,你可以通过`WWW`类或者第三方插件如`WWWForm`来获取文件数据,然后用`AssetBundle`或者`UnityWebRequest`来动态加载模型。以下是简单的步骤:
1. 使用WWW类:
```csharp
using System.IO;
WWW www = new WWW("https://remote.ruifbl.com/document/8608chanpin/room.fbx");
while (!www.isDone) {
// 模型未下载完成时,可以添加一些处理逻辑,比如显示加载中提示
}
string filePath = Application.streamingAssetsPath + "/your_custom_folder/room.fbx";
File.WriteAllBytes(filePath, www.downloadHandler.data);
```
2. 或者使用UnityWebRequest:
```csharp
using UnityEngine.Net;
UnityWebRequest request = UnityWebRequest.Get("https://remote.ruifbl.com/document/8608chanpin/room.fbx");
request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success) {
byte[] data = DownloadHandlerBinary.data(request);
string localFilePath = Path.Combine(Application.streamingAssetsPath, "your_custom_folder/room.fbx");
File.WriteAllBytes(localFilePath, data);
}
// 后续加载 AssetBundle 或者直接导入到场景
```
请记得替换"your_custom_folder"为你希望保存模型的本地目录。
阅读全文
相关推荐














