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. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How to correctly setup Scene Addressables

Discussion in 'Addressables' started by Uli_Dantas, Aug 7, 2018.

  1. Uli_Dantas

    Uli_Dantas

    Joined:
    Aug 21, 2014
    Posts:
    2
    Hi,
    I'm trying to setup an existing project that wasn't using asset bundles before, to use addressables.
    My setup is Unity 2018.2.1 and Addressable 0.2.1, my game consists of a Start scene, where the player simply chooses an button to load a minigame. The minigame will be a independent scene loaded in additive mode. When the minigame ends, the scene unloads and the player return to the main hub.

    What I'm trying to do is make each minigame scene addressable, so all it's content can be loaded and unloaded only when necessary.
    The problem is: I tried to add each scene to a content group, and set them to Pack Separately. In code I was able to load the scenes, but every single script component (my own components, for example, an MinigameBooController, MinigameBooPlayer) is missing after the scene loads.
    I'm using
    Code (CSharp):
    1. var asyncLoad = UnityEngine.AddressableAssets.Addressables.LoadScene(name, LoadSceneMode.Additive);
    and also tried to preload the dependencies before loading the scene like this:
    Code (CSharp):
    1. var preload = UnityEngine.AddressableAssets.Addressables.PreloadDependencies(name, null);
    I also tried to add the [UnityEngine.Scripting.Preserve] tag to each one of my classes, but it didn't work.

    So, how should I setup this? Do I need to add every single used prefab, model, texture, script along with the scene as addressable? Or the scene as addressable should automatically link the necessary dependencies.

    Also, using the scenes as adressables, should I remove them from the build settings? (It worked both ways, but no idea which is the correct way)

    I tested building to Standalone Windows, and WebGL build targets. Both didn`t work.

    Thanks
     
  2. PaulBurslem

    PaulBurslem

    Unity Technologies

    Joined:
    Oct 7, 2016
    Posts:
    41
    Hi, thanks for your feedback. I have reproduced this issue locally and we should have a fix soon. The problem is that when you make the group pack separately, the generated bundles use the name of the group and the address. When assets in sub directories resolve to the same address, this results in bundle name collisions. For now, you can work around this by ensuring that each scene has a unique address as the solution will probably involve detecting address collisions and giving more detailed error messages.
     
  3. Uli_Okm

    Uli_Okm

    Joined:
    Jul 10, 2012
    Posts:
    65
    Thanks @PaulBurslem, but the work around also didn't work.
    I tried pack then together too, but after the scene loads, my scripts are still missing.
    This is my setup:
    upload_2018-8-9_20-36-11.png

    I will just wait for the real fix for a while then :D