unity的Ready Player Me的QuickStart的加载服务器的glb模型,修改RPM Player预制体上的脚本改成下载到StreamingAssets文件夹然后加载,使其还是能正常运行
时间: 2024-05-24 18:11:40 浏览: 141
1. 将glb模型放到StreamingAssets文件夹中。
2. 打开RPM Player预制体,找到RPMPlayer.cs脚本。
3. 在RPMPlayer.cs脚本中,找到LoadAvatar()函数。
4. 将LoadAvatar()函数中的以下代码:
using (UnityWebRequest uwr = UnityWebRequest.Get(avatarURL))
{
yield return uwr.SendWebRequest();
if (uwr.result == UnityWebRequest.Result.Success)
{
byte[] bytes = uwr.downloadHandler.data;
avatar = GLTFSceneImporter.LoadFromBytes(bytes);
}
}
修改为:
string path = Application.streamingAssetsPath + "/avatar.glb";
UnityWebRequest uwr = UnityWebRequest.Get(path);
yield return uwr.SendWebRequest();
if (uwr.result == UnityWebRequest.Result.Success)
{
byte[] bytes = uwr.downloadHandler.data;
avatar = GLTFSceneImporter.LoadFromBytes(bytes);
}
5. 保存RPMPlayer.cs脚本,回到Unity编辑器界面。
6. 将RPM Player预制体拖到场景中,运行游戏,可以看到Avatar正常加载。
说明:以上修改后,RPM Player预制体将从StreamingAssets文件夹中加载glb模型,而不是从服务器上下载。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![unitypackage](https://img-home.csdnimg.cn/images/20250102104920.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)