外贸展示型网站建设公司,网络营销名词解释电子商务,东莞响应式网站建设定制,网站建设与设计摘要本地模拟服务器加载
1、创建一个Profiles#xff0c;将Remote设为Editor Hosted 2、在Addressables Group窗口将Profile设为Local Test 3、将某个Asset Groups设为Remote加载 4、Build资源 5、打开本地模拟服务器
Addressables Hosting 窗口是 Addressable 提供的一个内置本…本地模拟服务器加载
1、创建一个Profiles将Remote设为Editor Hosted 2、在Addressables Group窗口将Profile设为Local Test 3、将某个Asset Groups设为Remote加载 4、Build资源 5、打开本地模拟服务器
Addressables Hosting 窗口是 Addressable 提供的一个内置本地服务器工具用于在开发阶段快速测试远程资源加载功能无需搭建外部服务器环境。
WindowAsset ManagementAddressablesHosting 勾选Enable启动服务器 6、编写加载资源代码进行测试 可以在Hosting窗口看到有加载记录 成功啦
远程服务器加载
操作步骤
1、搭建服务器
参考该链接搭建IIS服务器
使用IIS搭建本地Web服务器-CSDN博客
2、创建一个Profiles将Remote设为Custom 需要自定义配置Remote.LoadPath格式是IIS服务器的ip地址加端口号 3、在Addressables Group窗口将Profile设为Remote Test 3、将某个Asset Groups设为Remote加载 4、在切换Profile之后最好先Clear Build Cache 4、Build资源 5、将远程打包资源复制到服务器中
找到项目根目录的ServerData文件夹将该资源拷贝到服务器上 6、补充如果在网页中双击.bunle文件出现 需要对.bundle文件进行MIME类型配置否则Addressable无法访问 7、编写加载资源代码进行测试 注意
1、Use Asset Bundle Cache启用时下载的 Asset Bundle 会被缓存到本地存储。下次加载相同资源时可以直接从本地缓存读取无需重新下载。在测试是否是从远程服务器加载时可以取消勾选进行测试。 2、在切换从本地加载Profile切换到远程加载Profile时发现资源加载还是加载旧的路。 需要在加载资源之前进行Addressable初始化检查更新
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.UI;public class Test : MonoBehaviour
{public Image img;private void Start(){CheckForUpdates();}public async Task CheckForUpdates(){// 初始化Addressablesawait Addressables.InitializeAsync().Task;// 检查catalog更新var checkHandle Addressables.CheckForCatalogUpdates(false);var catalogs await checkHandle.Task;if(catalogs ! null catalogs.Count 0){Debug.Log($发现{catalogs.Count}个更新);// 更新catalogvar updateHandle Addressables.UpdateCatalogs(catalogs);var locators await updateHandle.Task;}Addressables.LoadAssetAsyncSprite(Assets/Icons/icon_prop_2.png).Completed (asset) {img.sprite asset.Result;};}
}
3、如果有报下图中的错误可以尝试勾选Project SetttingsPlayerOther SettingsAllow downloads over HTTP