Search Unity

UriFormatException: Invalid URI: The hostname could not be parsed.

Discussion in 'Addressables' started by arvzg, Nov 1, 2018.

  1. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    619
    Unity 2018.2.11f1
    Addressables 0.4.6


    Code (CSharp):
    1. private void Awake()
    2. {
    3.    Addressables.LoadAsset<Sprite>("ArrowUp").Completed += OnLoaded;
    4. }
    5.  
    6. private void OnLoaded(IAsyncOperation<Sprite> op)
    7. {
    8.    Debug.Log("Done");
    9. }
    10.  
    This is giving me

    UriFormatException: Invalid URI: The hostname could not be parsed.


    upload_2018-11-1_19-4-13.png

    What am I doing wrong here?

    I've got the asset marked as Addressable:
    upload_2018-11-1_19-5-5.png
     
  2. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    619
    Seems this is only a problem when I load assets in Awake. If I change this to Start, everything's fine.

    Is this by design?
     
  3. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I think I saw that you shouldn't interact with the addressables system in Awake just yet.
    They seem to be working on getting it working, but for now it should be used after Awake.
     
    arvzg likes this.
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    You could try adding Completed callback on `Addressables.InitializationOperation` with logic in your Awake.
    Edit : This won't work, since the InitializationOperation property will call Initialize() which in turn have to use the string resolver which will be initialized for sure after Awake
     
    Last edited: Nov 5, 2018
    arvzg likes this.