Search Unity

Bad Address results in Exceptions (and not just a Status == Failure)

Discussion in 'Addressables' started by MasterControlProgram, Mar 9, 2020.

  1. MasterControlProgram

    MasterControlProgram

    Joined:
    Apr 18, 2015
    Posts:
    48
    We're having the following issue with trying to find an addressable that doesn't exist. The below very simplified example does what you expect. Returns status == Failure which is great. The problem is, in the process, it's also giving us 4 different exceptions. Any thoughts?

    Code (CSharp):
    1.  
    2. private void BadAddressTest()
    3. {
    4.     Debug.Log("Bad Address Test");
    5.     Addressables.LoadAssetAsync<GameObject>("bad_address").Completed += OnLoadDoneTest;
    6. }
    7.  
    8. private void OnLoadDoneTest(UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle<GameObject> obj)
    9. {
    10.     Debug.Log("OnLoadDoneTest" + obj.Status);
    11. }
    12.  
    And see attached screen grab for all the exceptions.
     

    Attached Files:

  2. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    Maybe surround the LoadAsset call with a try catch so the execution will not be interrupted?
     
  3. MasterControlProgram

    MasterControlProgram

    Joined:
    Apr 18, 2015
    Posts:
    48
    Yah we're currently doing that. But it feels like these exceptions shouldn't be thrown in this case. Wondering if this is an indicator of something problematic with our setup or something more sinister.
     
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
  5. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    [Unity 2018.4.18; Addressables 1.6.2]

    I have been replacing a lot of Resources.Load calls with Addressables.LoadAssetAsync and I am getting errors in the console whenever the key is invalid. I cannot silence it with try catch.

    I know I am giving a bad path but I want to try anyway and my console is being spammed with hundreds of errors which hides the real errors.

    Is there a way to have the addressables system handle it silently just like the resources system does?
     
  6. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    In the top level Addressable settings, uncheck
    Log Runtime Exceptions
    .
     
  7. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    Thanks a lot ProtoTerminator.

    The error do not appear in the console anymore.
     
  8. MasterControlProgram

    MasterControlProgram

    Joined:
    Apr 18, 2015
    Posts:
    48
    Sorry for the delay. I am on 1.6.2 Addressables. And 2019.3.1f1

    I'll try the uncheck of Log Runtime Exceptions. Thanks ProTerminator!