1.直接上最终结果
未修改配置和代码,重启,重新输入另一个加载地址,结果加载的是 Version2
2.过程
配置部分:打开Profiles面板
Window->AsserManager->Addressables->Profiles
在Remote.LoadPath中使用 {} ,{}里面的内容应该是根据反射获取到的变量
代码
namespace TestNamespace
{
public class TestClass
{
public static string TestStr = "192.168.101.16:12321";//根据这个来修改配置文件中的路径
}
}
public class TestRemoteLoadUILogic : MonoBehaviour
{
public InputField If_RemoteLoadPath;
public Button Btn_Refresh;
public Button Btn_Download;
public Button Btn_ShowLoginUI;
public Text Txt_Info;
bool uiwork = false;
public static string TestStr;//之前使用过Mono类来修改,好像没用,于是想是不是命名空间的问题,所以单独写个命名空间
private void Start()
{
//用来刷新地址
Btn_Refresh.onClick.AddListener(() =>
{
TestNamespace.TestClass.TestStr = If_RemoteLoadPath.text;
Txt_Info.text = $"-----刷新----\nRemoteLoadPath:{TestNamespace.TestClass.TestStr}";
});
//使用AA下载(里面代码网上应该有很多)
Btn_Download.onClick.AddListener(() =>
{
TestDownloadByAA.Instance.Work();
});
//加载资源
Btn_ShowLoginUI.onClick.AddListener(() =>
{
ResourcesManager.Instance.LoadAssetAsync<TextAsset>("Test/Test.txt", (asset) =>
{
Txt_Info.text = asset.text;
Resources.UnloadUnusedAssets();
});
});
}
}
3.解决的问题
Addressables需要热更的资源 服务器地址变动了 想动态修改获取资源的位置,但是在Addressables->Profile的时候写死了,想看看怎么可以修改RemoteLoadPath
4.工程(UNDONE)等啥时候有空了再传一个Demo上来好了