Search Unity

How do I load a .EDT file as an array of bytes using Addressables?

Discussion in 'Addressables' started by ConfusedExpert, Jun 3, 2020.

  1. ConfusedExpert

    ConfusedExpert

    Joined:
    Dec 25, 2014
    Posts:
    8
    Hello,

    I am trying to integrate Unity Addressables with EasyAR, by using Addresasbles to update the markers data that is needed for AR recognition.

    To achieve my goal, I need to find a way to convert a file markes as addressible with ".edt" extension to an array of bytes.

    I'm not sure how to do it though. EasyAR implements this using a WWW request on a local path, and the byte[] array is obtained via the method www.bytes,

    For me, I try to load the addressable using the method LoadAssetAsync<>(addressableName), but I am not sure about which generic type I should be passing to the method. I would love to pass <byte[]> as the generic type, but doing it throws this error:

    "Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Byte[]], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=Markers/Namecard, Type=System.Byte"

    Thanks in advance for the help.
     
  2. zhuxianzhi

    zhuxianzhi

    Joined:
    Mar 30, 2015
    Posts:
    122
    Change the file name to XX.edt.bytes
    Addressables.LoadAssetAsync<TextAsset>("key");
     
    Kirsche likes this.
  3. ConfusedExpert

    ConfusedExpert

    Joined:
    Dec 25, 2014
    Posts:
    8
    Thank you SO SO SO much mate!
    Works flawlessly!!
    I couldn't have done it without you. Cheers!