うにてぃブログ

主にUnityとC#に関する記事を書いていきます

【Unity】Addressable の Path を動的に変更する

Addressable の Path には Static なクラスの参照をもたせることができる

例えば以下のクラスのパスで置き換えたい場合は

public static class AddressableUtil
{
    public static string LoadPath;
}

このように記述すればカタログのロード時に置き換えることができる

カタログのファイルが以下のように記述されている場合

{AddressableUtil.LoadPath}/remote_assets_all_ee67f01f7232d38886308e65fcb21a0b.bundle

パスを指定してから InitializeAsync を呼び出すことで

        AddressableUtil.LoadPath = "http:/192.168.1.8:59595";
        
        yield return Addressables.InitializeAsync();

このようにパスが書き換わってロードすることができる

http:/192.168.1.8:59595/remote_assets_all_ee67f01f7232d38886308e65fcb21a0b.bundle