Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question AssetReference - Get Key or Name in build

Discussion in 'Addressables' started by Daerst, Jun 10, 2020.

  1. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    I am handling Scene Transitions using Addressables. My SceneTransition component has an AssetReference, so I can select which scene to load - awesome.

    Now I would like to preview the transition with a little text, something like "Go to Dock Area". To this end, I would like to get
    • either the Addressable's Key (if that's what it's called) that I manually set when making my Scenes adressables
    • or the name of the Scene Asset
    at runtime, in the build, so I can use that info to ask the Localization system for the "Go to Dock Area" string. Remember that the transition is not yet active, so the scene should not be loaded at this point.

    How would I do this?
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    566
    You can use
    AssetReference.RuntimeKey
    .
     
  3. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    That's e270dc4f68ba1ad4b8d5f6bec97f9211. Not exactly what I asked for.
    My Localization key is "Transition.TheSceneName", so I can't compare the hash to the localization keys directly.

    Any more ideas?
     
  4. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    566
    Hm, if that's not working, you should probably store the text key separately (maybe in a field next to the AssetReference?)
     
  5. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Once I'm convinced that there is no way to get either Addressable key or asset name at runtime, that's probably the way to go. Thanks for your help so far!
     
  6. Xavier78

    Xavier78

    Joined:
    Oct 13, 2013
    Posts:
    40
    Did you ever figure out a way to do this?
    I am also trying this, and unfortunately I can't get to how Addressables.LoadSceneAsync gets the name, just that it calls
    private AddressablesImpl m_Addressables;
    so AddressablesImpl.LoadSceneAsync
    Could someone shine some light on what AddressablesImpl does to load the scene from SceneManager?

    Or if there is a way to turn

    Edit. I got into the AddressablesImpl, and it seems the ResourceManager is being used to load scenes, I am very not familiar with how this is working, but I am assuming the reason names/sync scene loading isn't being used is because ResourceManager only works in Async?
     
    Last edited: Jun 22, 2023