0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Addressables.CheckForCatalogUpdatesが動作しない問題

Posted at

Unity6にてAddressablesを使ったリソース管理を実装しようと思い、ドキュメントを動作チェックをしていたところ、Addressables.CheckForCatalogUpdatesが想定した動きをしてくれません。

AddressableSample.cs
IEnumerator CheckCatalogs()
{
    List<string> catalogsToUpdate = new List<string>();
    AsyncOperationHandle<List<string>> checkForUpdateHandle
        = Addressables.CheckForCatalogUpdates();
    checkForUpdateHandle.Completed += op => { catalogsToUpdate.AddRange(op.Result); };

    yield return checkForUpdateHandle;

    if (catalogsToUpdate.Count > 0)
    {
        AsyncOperationHandle<List<IResourceLocator>> updateHandle
            = Addressables.UpdateCatalogs(catalogsToUpdate);
        yield return updateHandle;
        updateHandle.Release();
    }

    checkForUpdateHandle.Release();
}

想定した動きとはcatalogsToUpdate.Countにて1以上の値が返ることですが……

  1. 環境AにてAddressablesを使ってリソースをビルドし、出力をアップロード
  2. 環境Bにて実行してInitializeAsyncを呼ぶ(ついでにリソースを読み込み内容を確認
  3. 環境Aにて1.の内容を変更してリソースをビルドし、出力をアップロード
  4. (実行したままの)環境BにてCheckForCatalogUpdatesを呼ぶ

この手順でcatalogsToUpdate.Countは常に0が返します。

以下の方法で直接パッケージの中身を読んでみました。
https://someiyoshino.info/entry/2021/12/26/180355

するとCanUpdateContentの中で以下のコードを発見しました。
これは現状の動作的には==3であることが正しいはずです。

CatalogLocation.Dependencies.Count==2

そこで検索したところ、以下のやり取りを発見
https://discussions.unity.com/t/addressable-checkforcatalogupdates-does-not-work/1516925/18

==3にする、もしくは執筆時の最新バージョン[2.3.16]をインポートすること(※)でCheckForCatalogUpdatesが想定した結果を返すようになりました。

今回チェックした時点のUnityのバージョンは[6000.0.35f1]なのですが、現状はPackageManagerを使ってインポートされるAddressableのバージョンは[2.2.2]なので、他にも困ってる人がいるかもしれないので記事にしておきます。

(※)
[project]/Package/manifest.jsonに記載されている"com.unity.addressables"のバージョンを書き換える

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?