Search Unity

Is it possible to download ReferenceImageLibrary via Assetbundle and load it in run time?

Discussion in 'Getting Started' started by yinzcam, Feb 20, 2023.

  1. yinzcam

    yinzcam

    Joined:
    Aug 2, 2016
    Posts:
    3
    I'm trying to use ARFoundation but one of our requirement is to be able to swap the Marker without making a new build. Because MutableReferenceImageLibrary is not supported by all devices, I chose to use Assetbundle approach. In the documentation of ARFoundation 4.2, it says loading from Assetbundle is possible after 4.2. Therefore I used 4.2.7 for ARFoundation, ARKit and ARCore. However, it doesn't work. Although it successfully downloaded Assetbundle and loaded ReferenceImageLibrary from Assetbundle, it cannot detect the markers in the library. I'm using the following code after the library is loaded from Assetbundle.

    Code (CSharp):
    1. Debug.Log("Load ReferenceImageLibrary Successful!");
    2.  
    3. var manager = gameObject.AddComponent<ARTrackedImageManager>();
    4. manager.enabled = false;
    5. manager.requestedMaxNumberOfMovingImages = 1;
    6. manager.trackedImagePrefab = m_prefab;
    7. //imageLibrary is loaded from Assetbundle
    8. manager.referenceLibrary = manager.CreateRuntimeLibrary(imageLibrary);
    9.  
    10. manager.enabled = true;
    Is this an ARFoundation bug? Or am I doing anything wrong?