Search Unity

Can't load assets

Discussion in 'Addressables' started by jesta, Jul 25, 2018.

  1. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    294
    I'm on 2018.2.0x-ImprovedPrefabs

    I have .asset (ScriptableObject) addressed as "GameSettings". I try loading it this way:
    Code (CSharp):
    1. GameSettings = Addressables.LoadAsset<GameSettings>("GameSettings").Result;
    The result is always null. The same applies to any other type of object I try to load.
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    The LoadAsset call is asynchronous (along with all calls in Addressables), so you must wait for the completed callback, and then get the Result.

    Thanks for trying out the system, please let us know of any other issues,
    Bill
     
  3. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Is there a way to synchronously load the assets? IE Blocking? Async is all well and good when needed but horrendously complicates code when not. I'm trying to convert over an editor based tool and it is getting very complex and confusing to try and shoehorn async loading into things.
     
  4. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    There's an excellent reply from @unity_bill about the difficulties with sync loading that might be worth reading: https://forum.unity.com/threads/my-addressables-feedback.537610/#post-3575862

    I'm also wondering what's the recommended way of blocking until the asset is loaded.
    For system parts that should be loaded at startup, I can think of using a preloading routine that will request the assets and wait in a co-routine until they are loaded, before loading the rest of the system. That's what I already do currently, with scenes and bundles.

    For everyday references, I'm not sure what's the current recommended way. We can easily fall into callback hell due to the added complexity of async and dependencies.
     
  5. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Well the largest problem I am dealing with is the archetecture of the tool was never designed to be anything but synchronous. The only reason I want to use addressables in the first place is to avoid the problem of GUIDs being an insufficient method of tracking asset connections. This new system will let us track assets by an asset path rather than a GUID.

    Can I even use coroutines in editor scripts?
     
  6. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395