Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Bug? v1.1.4] Content not updating

Discussion in 'Addressables' started by MaskedMouse, Jul 10, 2019.

  1. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    I'm trying the latest version of the addressables.
    Though I am encountering a problem where content isn't updated.

    I have 2 remote groups where:
    - SceneGroup contains 1 scene
    - PrefabGroup contains 1 prefab

    I have 1 Loader scene which is packed with the build and is not addressable.
    The loader scene contains a script which calls
    await Addressables.LoadSceneAsync(SceneReference, LoadSceneMode.Additive).Task;
    on
    async void Start()


    Steps that I did:
    - The prefab is dragged into the scene.
    - Scene is saved.
    - Addressables are built to the "remote" location
    - I'm turning on the Hosting Services.
    - I build the Windows x64 player.
    - I run the build.
    - The scene loads additive and I see the content.

    Now I update the prefab, I change my dynamic content.
    - So I add another cube or cylinder to it and save the prefab.
    - I build the content again, a new catalog is made with a new asset bundle.
    - I run the player without rebuilding.
    - The content is loaded from cache instead of being updated from the "remote" location.
    - The new catalog is not loaded.

    Conclusion:
    it is loading from cache instead of loading the updated bundles.

    The whole reason for using addressables is to dynamically update content without rebuilding the player.
    It worked in the past but with 1.1.4 I can't seem to get it to work anymore. It keeps loading the old content, event though the remote has already been updated.

    Is this a bug or do I have to do things differently to update my content from remote?
     
  2. AlexisDev

    AlexisDev

    Joined:
    May 11, 2016
    Posts:
    2
    Same issue here, but it's working in the editor with Play Mode Script set to Packed Play Mode.
    My target is Android and I've unchecked Use Asset Bundle Cache and Use Asset Bundle Crc.
    Update if you've got any progress on this please.
     
  3. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    A few comments...

    first
    Note that you can't use Android bundles in the editor. If your editor is current set to Android, and you build bundles, then enter play mode in Packed mode, it won't work. Unless your editor was running on an android device. which it can't. You have to build windows/mac bundles to run packed mode in-editor.


    second (and not actually all that relevant)
    Just want to make a note that if the prefab is in the scene, then the prefab bundle is not used. If a scene has a game object in it that is tied to a prefab, that prefab gets flattened into the scene during build. Note this is not the case for the dependencies of that prefab, such as a texture. If instead the scene has a game object with a script that loads/instantiates a prefab, then things work as you'd expect. Most likely not related to your issue, just fyi.

    Are you sure we aren't loading the new catalog? Could be we are, but things go wrong elsewhere. I'm just curious how much you dug into the code to see where things actually go off the rails. Regardless, if you can file a bug against Unity for this with a repro project, that'd help us get to the bottom of it. Or feel free to do some debugging on your own and give us info (you can probably work around it temporarily by turning off Use Asset Bundle Cache)
     
  4. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Well requireing to have a script that loads / instantiates a prefab is not really a great workflow.
    In my case it will be a lot of UI and changes to the UI in that scene. Changing the prefab in Prefab mode does not dirty the scene. So the Scene never knows it has been changed, thus it doesn't update the scene bundle.

    Hypothetically if you'd have a big environment inside a scene and change a prefab of that scene through prefab mode, it should update the scene bundle because the scene has changed, but it doesn't. A change in the prefab doesn't dirty the scene. And instantiating all those prefabs from a script is kind of a weird way to go for it. You'd have to split authoring and instantiating or not use prefabs at all (but that beats the purpose of nested prefabs. Change 1 prefab, change all instances in the scene).

    It is exactly how I solved it in the past, but it is just a weird workflow. Have GameObjects with a script that instantiates the UI. Which then instantiate all their own prefabs as well. So it builds up the UI bit by bit.
    But for authoring the full UI, I currently have a seperate scene that isn't included into the build just to make UI changes where everything is already instantiated.

    I haven't looked much at the code yet. Will have to debug this step by step and check what happens.
    I'd have to carefully look for what catalog is being loaded. If it is still the old one then there might be a bug.
     
  5. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Agreed that this isn't necessarily the right workflow (sometimes it is). I was not suggesting you should do things that way, just letting you know that's what happens. As to the prefab editing not dirtying the scene, I'll look into that. It should. Perhaps not from a VCS/file-system standpoint, but definitely from a build one. Made a ticket in our system to check this out.

    Of note, what if PrefabGroup didn't exist? If only the scene is addressable, does it update properly? If you aren't spawning that prefab from code (it's only in the scene), then you really don't want that prefab to be addressable.
     
  6. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Ok so now I only have a scene as a remote bundle.
    The prefab is located somewhere in the project but not addressable. But the prefab is instantiated inside the scene.

    Steps I've taken:
    - I went into the remote scene
    - clicked the ">" behind the prefab
    - Added another cube.
    - Saved the prefab and exited Prefab Mode
    Note: Scene detects no changes. No * behind the scene name.
    - I build the addressables again (in the hope it would still update the scene bundle)
    - Fireup my loader scene. (using packed mode)
    I notice it does load the newest catalog through the debug log.
    But the scene that is getting loaded contains 1 cube instead of 2 that I just added in prefab mode.


    The loader scene contains a gameobject with this script attached.
    The SceneReference is serialized with the remote scene.
    Code (CSharp):
    1. public class LoadAddressableScene : MonoBehaviour
    2. {
    3.     public AssetReference SceneReference;
    4.  
    5.     public async void Start()
    6.     {
    7.         await Addressables.LoadSceneAsync(SceneReference).Task;
    8.     }
    9. }

    If I turn off Use Asset Bundle Cache and build the bundle again. It does load the scene with 2 cubes.
    But like I said changing the prefab in prefab mode doesn't dirty the scene. So the bundle doesn't get updated and the bundle is loaded from cache. That's what I think that happens.
     
  7. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    hmm. the fact that turning off cache works means (probably) we're building the right bundle, but have something wrong in the cache-checking at runtime. Or it's building wrong. Regardless, it's definitely a bug, and definitely something we'll dig into.

    One more bit if you don't mind, what version of the editor are you running? This seems like it might be tied to the prefab editing workflow, which has changed a bit over the past few releases.
     
  8. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,091
    Using Unity 2018.4.4 LTS
     
    unity_bill likes this.
  9. AlexisDev

    AlexisDev

    Joined:
    May 11, 2016
    Posts:
    2
    Well you say that I can't use Android bundles in the editor but that works fine. Or maybe I am missing something and Unity uses an alternative mode under the hood ? Target is set to Android, Graphics API to OpenGL ES 3.2 (to display correctly the materials) and Addressables play mode script to Packed Play Mode.
    When I try to load an addressable I can see that it connects on my IIS server and try to load from there, in fact if I turn the server off I get an error in the console.

    My setup is simple :
    • Only one scene is included in my build
    • This scene has a script that can load another scene (not included in the build settings but loaded via addressables)
    My scene is in a special group with Use Asset Bundle Cache and Static Content disabled.
    Then my test is the following :
    • Build the APK and the bundle, upload the bundle online and launch the APK
    • The addressable scene is loading fine with its content correct
    • I change the scene content and then Addressables -> Build -> Build For Content Update, I upload the resulting files and restart the APK (without a rebuild)
    • The loaded scene is the same as before, no way to get the correct scene despite unity loading from the correct bundle (it seems, according to the console when in editor mode). Only an APK rebuild fixes the issue.
    I still have to update to 1.1.5 just in case, my test version is 1.1.4
    and I'm using Unity 2019.1.7f1

    Thanks for your help
     
  10. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    It is loading android data for you (or at least should be). What I should have said is "Android built data often won't work in editor". Sometimes it will, sometimes not. It depends on the type of asset. Some assets are generic enough when built that they work anywhere. Many asset types however, are going to be built in such a way that they can't work on a PC. Mainly this will be textures or shaders depending on the settings.

    So I guess I'd say "use android in-editor at your own risk"
     
  11. Ranadheer_ivy

    Ranadheer_ivy

    Joined:
    Nov 7, 2022
    Posts:
    1
    Is this solved? If yes please help me with the solution. I am also facing same issue.
    Unity Editor : 2019.4.29f1
    Addressables : tried with 1.19.19 and 1.21.10 but no luck.

    Thanks in advance.