Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Previous build not updating addressable changes

Discussion in 'Addressables' started by Mitjans_AmuseNetwork, Jan 11, 2019.

  1. Mitjans_AmuseNetwork

    Mitjans_AmuseNetwork

    Joined:
    Aug 3, 2017
    Posts:
    1
    I have observed that when I make some changes in my remote bundles and upload them to the server, my previous builds do not update their content. To try to isolate the problem I have create a new project where I instantiate prefabs with a certain label, and I still get the same issue:


    I have created a remote group that contains textures and prefabs and I have added a label to my prefabs. I then instantiate all the prefabs from my server (it all works fine). When I change the label and I rebuild/update my bundles, Unity creates a new ‘catalog_***.json’ and ‘**.hash’ files, which I upload with everything else to the server. If I then try to Instantiate again from a build already created, it still instantiates the old labeled prefabs, not the new ones. If I create a new build, it gets the proper labelled prefabs as it should. Here is the code:


    public AssetLabelReference labelRef;

    private void InstantiateAddressablesWithTag()
    {
    Addressables.LoadAssets<GameObject>(labelRef.labelString, null).Completed += OnAllLoaded;
    }

    private void OnAllLoaded(IAsyncOperation<IList<GameObject>> operation)
    {
    if (operation.Status == AsyncOperationStatus.Succeeded)
    {
    var result = operation.Result;
    int count = result.Count;
    for (int i = 0; i < count; i++)
    {
    GameObject go = Instantiate(result[i]);
    go.transform.position = UnityEngine.Random.insideUnitCircle * 10f;
    }
    }
    else
    {
    Debug.LogError("could not load objects with label: " + labelRef.labelString);
    }
    }


    I made sure that my bundles are marked as non ‘Static Content’, but it seems like the previous remote catalog (from previous version) still contains the old labels. I don’t understand what is happening as in my isolated project everything seems to work fine and there is nothing else in the code. I thought the already builded players should update their content from remote if any changes were found. I have also tried to clean the cache to force re-downloading the bundles.

    I have also done the ‘Build for Play Content’ procedure even though my addressables are dynamic and I thought this step wasn’t necessary and the issue was not solved.

    Also, the first time I launched play packed mode I got this exception, though I am not sure it is related (check attached image).

    What am I missing?


    For extra info: my unity version is 2018.3.1 and I am using Addressables System version 0.5.3.



    Thank you for your help!
     

    Attached Files:

    Muramasa666 and MNNoxMortem like this.
  2. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    120
  3. rootor

    rootor

    Joined:
    Apr 7, 2013
    Posts:
    2
    If you are using 0.5.3 I think I know what the issue is. Each time you build the bundles the catalog file gets named by the current timestamp, e.g. catalog_xyz.* where 'xyz' is the time it was built. A client built with a certain catalog file will always download the same file with the timestamp it was built with. This means that even if you build new bundles and upload to the server the old client won't know about the new catalog file.

    I have solved it for now by building bundles with a hardcoded playerVersion (Basically cloning what is in
    AddressableAssetSettings.BuildPlayerContent() but passing "1" as playerVersion):

    Code (CSharp):
    1. public class BuildAddressables
    2. {
    3.     [MenuItem("Assets/Build Addressables")]
    4.     public static void Build()
    5.     {
    6.         Debug.Log(
    7.             $"Building Addressables Player Content to {Addressables.BuildPath}/{EditorUserBuildSettings.activeBuildTarget}");
    8.  
    9.         var settings = AddressableAssetSettingsDefaultObject.Settings;
    10.         if (settings == null)
    11.         {
    12.             Debug.LogError("Addressable Asset Settings does not exist.");
    13.             return;
    14.         }
    15.         if (Directory.Exists(Addressables.BuildPath))
    16.         {
    17.             try
    18.             {
    19.                 Directory.Delete(Addressables.BuildPath, true);
    20.             }
    21.             catch (Exception e)
    22.             {
    23.                 Debug.LogException(e);
    24.             }
    25.         }
    26.  
    27.         var buildContext = new AddressablesBuildDataBuilderContext(settings,
    28.             BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget),
    29.             EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.development,
    30.             false, "1");
    31.         settings.ActivePlayerDataBuilder.BuildData<AddressablesPlayerBuildResult>(buildContext);
    32.     }
    33. }
    This way all clients, no matter when they were built, will always look at catalog_1.* and properly update content if hashes have changed.

    It can also be useful to set the 'ADDRESSABLES_LOG_ALL' preprocessor symbol in your project settings. It will print which catalog files are downloaded etc.
     
    MNNoxMortem likes this.
  4. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    120
    @rootor wow. I will have to try that, that sounds incredibly useful for us. Thanks!
     
  5. MomochaZ

    MomochaZ

    Joined:
    Jun 20, 2013
    Posts:
    25
    Hello

    I have tried this method but the assets still doesn't update.
    The addressable log shows that it use the cache catalog_1 and doesn't update from remote.

    Does @MNNoxMortem update successfully?

    Thanks.
     
  6. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    120
    @MomochaZ no because most changes we do are not detected by the the Prepare for Content Update. Some changes definetly do, but others don't and therefore we stopped even trying until the next release.