コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】Addressables を導入しているプロジェクトで再生に時間がかかる場合は AssetReference が原因の可能性がある

概要

Addressables 1.18.16 あたりから AssetReference のコンストラクタで

/// <summary>
/// Construct a new AssetReference object.
/// </summary>
public AssetReference()
{
#if UNITY_EDITOR
    EditorApplication.playModeStateChanged -= ReleaseHandleWhenPlaymodeStateChanged;
    EditorApplication.playModeStateChanged += ReleaseHandleWhenPlaymodeStateChanged;
#endif
}

イベントの登録と解除が行われるようになった
その関係で AssetReference をたくさん使っているプロジェクトだと
Unity の再生時に数十秒待ち時間が発生することがあるらしい