Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug URGENT: CCD TextAsset Addressables fails

Discussion in 'Unity Cloud Content Delivery' started by darashayda, Oct 10, 2021.

  1. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    To CCD Staff:

    We need to create CCD projects and buckets that are populated by third party software not Unity Editor.

    In particular geometry assets e.g. we need to upload .obj files into CCD for very exotic shapes.

    CCD allows for direct uploads which we could immediately take advantage of. Mind you we already built our own system for such operations for about a year now, but pieces of functionality are missing which CCD provides rather well.

    However no matter what we did we could not download any TextAssets from the CCD no matter how we arranged the file extensions and file modes (RW).

    This is a general issue in Addressables, please see their forums, however we need to solve this problem immediately in CCD or 90% of its utility is lost for our projects!

    Please see the code below. You could also enter .txt or text or .binary. Bucket is public feel free to upload download workaround if need be.

    Key=https://79783c29-bb9b-456a-ae26-bca...e/latest/entry_by_path/content/?path=nav2.obj

    Enter this URL into any browse and you can see the Asset Key created by CCD works, then the Asset Key is good:

    # Created with the Wolfram Language : www.wolfram.com
    # {}
    g default
    s off
    v -0.3303311608651652 -1.7382996605858778 0
    v -0.12940109358307478 -1.7258220104170805 0
    v -0.18225154054844933 -1.4730067064431334 0
    ...


    The code below fails, while it works for other assets created by Unity itself via the Addressables Group:

    Unity 2021.1.3f1
    macOS Big Sur

    ...
    string release = "https://79783c29-bb9b-456a-ae26-bca..._by_badge/latest/entry_by_path/content/?path=";

    string asset = "nav2.obj";

    string key = release+asset;

    AsyncOperationHandle <TextAsset> handle = Addressables.LoadAssetAsync<TextAsset>(key);
    handle.Completed += loadexternal2;
    }
    private void
    loadexternal2(AsyncOperationHandle<TextAsset> handle)
    {
    Debug.Log("handle success !!!");
    Addressables.Release(handle);

    }



    Errors
    Exception encountered in operation CompletedOperation, status=Failed, result= : Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=https://79783c29-bb9b-456a-ae26-bca...e/latest/entry_by_path/content/?path=nav2.obj, Type=UnityEngine.TextAsset
    UnityEngine.AddressableAssets.Addressables:LoadAssetAsync<UnityEngine.TextAsset> (object)
    LoadExternal:loadexternal () (at Assets/LoadExternal.cs:107)



    Dara
     

    Attached Files:

    Last edited: Oct 11, 2021
  2. llunity3d

    llunity3d

    Unity Technologies

    Joined:
    Aug 23, 2021
    Posts:
    24
    Hi Dara,
    Thanks for your feedback, we will be investigating and come back to you on this one.
    Thanks again for using CCD!
     
  3. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    We will really really appreciate to fix this problem, we have a workaround for a year in place, but defeats the purpose of CCD. I like to nix any other code that does what CCD does and focus on what else CCD does not do.

    Dara
     
  4. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    We are in need of proper resolution of this issue , so we can complete our cloud interface.

    Thank you.
     
  5. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    For the Addressables error, this will be expected. By default anything you put into Addressables Groups is built into AssetBundles and is accessable by the keys like the address use to identify the asset. From the keys Addressables will internally find what was built and how to load it.

    In order to use raw files, outside of the bundle build. You will have to extend the Addressables build script to not build the files into the bundles, and instead generate different locations for how you want to locate the files.

    If you want to just download files like your code suggest, and not have the use of addressables keys. Then you could just download the file directly.
    Alternatively, if you just want to use the Addressables API. Without the locators, you can create a Location at runtime and ask Addressables to process the download.
    Something like the following:

    Code (CSharp):
    1. IResourceLocation addrLocation = new ResourceLocationBase("nav2", "https://79783c29-bb9b-456a-ae26-bca..._by_badge/latest/entry_by_path/content/?path=nav2.obj", typeof(TextDataProvider).Name, typeof(string));
    2. Addressables.LoadAssetAsync<string>(addrLocation);
    These are the key points of Addressables in relation to the problem
    - Addressables builds, bundle Assets to AssetBundles and generates Locations for how to find the Assets based on keys.
    - Runtime, you ask Addressables using a key for an Asset, it then gets the Location data from the build and will get the Asset from it.
    - To use Addressables outside of the bundle builds. You need to generate the Locations, and either use them directly or add them to the internal Locators.

    Thanks,
    Andy
     
    Last edited: Oct 22, 2021
  6. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    EXCELLENT! I will work them in coming hours... Thank you!
     
  7. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    While I fully understand that you explained, still my code is not working. Mind you downloaded the latest version for Addressables. And again the Editor is 2021.2.0b15.


    string release = "https://79783c29-bb9b-456a-ae26-bca..._by_badge/latest/entry_by_path/content/?path=";

    string asset = "nav2.obj";

    string key = release+asset;

    IResourceLocation addrLocation = new ResourceLocationBase("nav2", key, typeof(TextDataProvider).Name, typeof(string));
    // Debug.Log(addrLocation);
    AsyncOperationHandle<string> handle = Addressables.LoadAssetAsync<string>(addrLocation);
    handle.Completed += loadexternal2;
    ...



    private void
    loadexternal2(AsyncOperationHandle<string> handle)
    {

    if (handle.Status == AsyncOperationStatus.Succeeded)
    {

    Debug.Log(handle.Result);
    }

    }

    error:
    System.NullReferenceException: Object reference not set to an instance of an object
    at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].Execute () [0x00061] in...
     
  8. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    Apologies, typeof(TextDataProvider).Name is meant to be typeof(TextDataProvider).FullName
     
  9. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    With great pride and joy, Happy Joy Joy! It works amazingly well :)

    Thank you.

    I will discuss a documentation issue with David S, who deals with our corporate account, and if possible join us if you could.

    Reason I should be able to do these debugs myself, and I cannot due docs issues.

    But we are now 100% functional, using purely CCD+Addressables with Group Addressable and even with External assets.

    Again thank you :)

    I owe you big!

    Dara
     
  10. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    Please mark this resolved TOMORROW, because we will test tonight.
     
  11. darashayda

    darashayda

    Joined:
    Jun 27, 2020
    Posts:
    442
    All works now!

    I am going to leave this CCD bucket public so others could coed against it!