下载Addressables插件
打开Addressables Groups组设置
创建组
设置路径
新建一个cube测试,拖到资源文件夹,作为预制体,然后拖到RemoteGroup里面。
设置模式
打一下包
找到以下文件夹,文件夹里面的文件为建立好的文件
新建脚本,添加一下代码测试。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
public class DataTest1 : MonoBehaviour
{
void Start()
{
Addressables.LoadAssetAsync<GameObject>("Assets/Prefabs/Cube.prefab").Completed += (handle) =>
{
GameObject prefabobj = handle.Result;
GameObject cube = Instantiate(prefabobj);
};
}
// Update is called once per frame
void Update()
{
}
}
注意路径"Assets/Prefabs/Cube.prefab",为预制体的路径。
打开网络文件服务器,这里我用的HFS,将刚才生成的文件和父文件夹拖入
回到unity,设置RemoteGroup的加载和建立路径。
删除cube预制体,进行测试。