Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

InstantiateAsync().Completed is never called

Discussion in 'Addressables' started by AcuityCraig, Mar 24, 2020.

  1. AcuityCraig

    AcuityCraig

    Joined:
    Jun 24, 2019
    Posts:
    15
    Hello,

    I have an AR app I am migrating to addressables. In the editor my code works fine. I am testing with the HTTP host on an android and the InstantiateAsync().Completed even is never called. It does find the assets and does not throw any errors, just never calls the event. I'm using 1.6.2 since 1.7 would not let me build asset bundles.

    Code (CSharp):
    1. private void PlaceObject()
    2.     {
    3.         Debug.Log("placing object");
    4.         if (GameManager.Instance.fixtureToSpawn.RuntimeKeyIsValid())
    5.         {
    6.             //Create the object
    7.             //GameObject go = Instantiate(GameManager.Instance.fixtureToSpawn, placementPose.position, placementPose.rotation);
    8.             GameManager.Instance.fixtureToSpawn.InstantiateAsync(placementPose.position, placementPose.rotation).Completed += FinishPlacement;
    9.             Debug.Log("runtime key was valid");
    10.         }
    11.     }
    12.  
    13.     private void FinishPlacement(AsyncOperationHandle<GameObject> obj)
    14.     {
    15.         Debug.Log("finishPlacement called");
    16.         if (obj.Status == AsyncOperationStatus.Succeeded)
    17.         {
    18.             Debug.Log("status succeeded");
    19.             GameObject go = obj.Result;
    20.             SelectableFixture s = go.GetComponent<SelectableFixture>();
    21.             go.name = s.fixtureName;
    22.             //Add a line renderer if the fixture is not grounded so user can measure height
    23.             if (!s.isGrounded)
    24.             {
    25.                 GameObject heightmeasurer = Instantiate(heightMeasurementObject);
    26.                 heightmeasurer.transform.SetParent(go.transform);
    27.                 heightmeasurer.transform.localPosition = Vector3.zero;
    28.                 s.heightMeasurement = heightmeasurer.GetComponent<ChangeHeightMeasurement>();
    29.                 s.heightMeasurement.startYpos = go.transform.position.y;
    30.                 s.startingSurfaceHeight = go.transform.position.y;
    31.  
    32.             }
    33.             GameManager.ForceSelectFixture(go);
    34.             //Create History and store the object so it can be undone
    35.             AddHistory t = new AddHistory(go);
    36.             GameManager.AddHistory(t);
    37.             //ReportFixtureSpawned for analytics on which fixtures specifically are being created the most.
    38.             //ReportFixtureSpawned(go.GetComponent<SelectableFixture>().fixtureName);
    39.             if (FixtureAddedEvent != null)
    40.             {
    41.                 FixtureAddedEvent();
    42.             }
    43.         }
    44.         else
    45.         {
    46.             Debug.Log("Async load failed");
    47.         }
    48.     }
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    210
    I'll flag this for the team to have a look - which version of the editor are you using?
     
  3. AcuityCraig

    AcuityCraig

    Joined:
    Jun 24, 2019
    Posts:
    15
    2019.2.5f1

    currently on addressables 1.6.2 due to the bug in 1.7 where bundles fail to build
     
  4. AcuityCraig

    AcuityCraig

    Joined:
    Jun 24, 2019
    Posts:
    15
    This issue appears to have been resolved by updating to 1.7.5.
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    210
    Excellent! Thanks for the udpate!
     
unityunity