Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Maxst AR SDK Instant Tracker - loading resources from server Unity Addressable

Discussion in 'Scripting' started by VenoliS, Aug 10, 2020.

  1. VenoliS

    VenoliS

    Joined:
    Jul 29, 2020
    Posts:
    2
    Hi,

    I want to load resources from a server and use it with Maxst AR SDK instant tracker. I have tried two ways using Unity Addressable but still, I can't get the AR behaviour. Anyone who familiar with Maxst AR SDK please help.

    1st way:

    Here I have created an InstantTrackableBehaviour public variable (prefab in the below code) and dragged an instantTrackable prefab from unity inspector window. Then when a button press I loaded my 3D object from server and attach it as a child to instant trackable and instantiate it like below code.

    var locations = await Addressables.LoadResourceLocationsAsync(label).Task;

    foreach (var location in locations)
    {

    InstantTrackableBehaviour instantTrackable = InstantTrackableBehaviour.Instantiate(prefab) as InstantTrackableBehaviour;
    GameObject obj = await Addressables.LoadAssetAsync<GameObject>(location).Task;

    obj.transform.parent = instantTrackable.transform;
    Instantiate(obj);
    instantTrackable.OnTrackFail();
    }



    Here the object is loading but it doesn't have AR behaviour. just moving with the mobile screen.

    2nd way:

    Here I created an addressable from InstantTrackable prefab that has attached a child 3d object. Then I'm tried to load it from server and instantiate.

    var locations = await Addressables.LoadResourceLocationsAsync(label).Task;

    foreach (var location in locations)
    {

    InstantTrackableBehaviour instantTrackable = await Addressables.LoadAssetAsync<InstantTrackableBehaviour>(location).Task;
    InstantTrackableBehaviour instantTrackable2=InstantTrackableBehaviour.Instantiate(instantTrackable) as InstantTrackableBehaviour;
    instantTrackable2.OnTrackFail();

    }



    This led me to the below exception.

    Exception encountered in operation Resource<InstantTrackableBehaviour>(InstantTrackable (1).prefab): Unknown error in AsyncOperation



    How can I load resources from a server and use it in the Maxst instant tracker?

    Thank You!