Search Unity

How to reset cached evaluated {path} of Addressable?

Discussion in 'Addressables' started by Kamyker, Jan 28, 2020.

  1. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Currently my load path for externally exported Addressables packages is set to
    Code (CSharp):
    1. {MapLevel.CurrentMapPath}/UnityData/[BuildTarget]
    For ex. this code:
    Code (CSharp):
    1. MapLevel.CurrentMapPath = "something";
    2. var catalogPath = myPathHere;
    3. Addressables.LoadContentCatalogAsync( catalogPath ).Completed += obj =>
    4. {
    5.     if ( obj.Result != null )
    6.     {
    7.         Addressables.AddResourceLocator( obj.Result );
    8.         foreach ( var item in obj.Result.Keys )
    9.         {
    10.             //handling resources here
    11.         }
    12.         Addressables.RemoveResourceLocator( obj.Result );
    13.     }
    14.     Addressables.Release( obj );
    15. };
    Works fine until I run it again with different package. If on the 2nd run I change
    Code (CSharp):
    1. MapLevel.CurrentMapPath = "something2";
    then do for ex.
    Addressables.LoadAssetAsync<SomeObject>( item )
    the
    MapLevel.CurrentMapPath 
    is still evaluated (or cached?) to old ""something" and I get wrong path and missing file exception. How do I remove cached value and reevaluate {MapLevel.CurrentMapPath}?
     
  2. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    FixItFelix and Samuel411 like this.