[Helpe] How to load ReferenceImageLibrary from assetbundle or addressable

Is loading from assetbundle supported?
I’m using the ARFoundation!
I tried set it from adressable but it was throwing an exception.
below is my exception log:

 [General] No resource group with name "ReferenceImageLibrary_F9826AB7-B00D-45C3-BB5E-C1090EB7CF4F" found
InvalidOperationException: Failed to set requested image library 'ReferenceImageLibrary' on ARKit - there is no matching resource group, or the resource group does not contain any reference images.
  at UnityEngine.XR.ARKit.ARKitImageTrackingSubsystem+Provider.set_imageLibrary (UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary value) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem.Start () [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`2[TSubsystem,TSubsystemDescriptor].OnEnable () [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.Behaviour.set_enabled (System.Boolean value) [0x00000] in <00000000000000000000000000000000>:0
  at ARPropertiesManager.<StartImageTracking>b__23_0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] _handle) [0x00000] in <00000000000000000000000000000000>:0
  at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
  at DelegateList`1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider+InternalOp.ActionComplete (UnityEngine.AsyncOperation obj) [0x00000] in <00000000000000000000000000000000>:0
  at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.AsyncOperation.InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0

My Solution:
TIPS:We need to update the arfoundation & arkit to 3.0.
This _handle.Result is load from assetbundle. and _handle.Result is a ReferenceImageLibrary.

MutableRuntimeReferenceImageLibrary tmp_RuntimeReferenceImageLibrary =
                ArTrackedImageManager.CreateRuntimeLibrary() as MutableRuntimeReferenceImageLibrary;
            foreach (XRReferenceImage tmp_ReferenceImage in _handle.Result)
            {
                JobHandle tmp_JobHandle = tmp_RuntimeReferenceImageLibrary.ScheduleAddImageJob(
                    tmp_ReferenceImage.texture,
                    tmp_ReferenceImage.name, tmp_ReferenceImage.width);
                tmp_JobHandle.Complete();
            }

            if (tmp_RuntimeReferenceImageLibrary != null)
            {
                Debug.Log("tmp_RuntimeReferenceImageLibrary: " + tmp_RuntimeReferenceImageLibrary.count);
                Debug.Log(
                    "supportedTextureFormatCount: " + tmp_RuntimeReferenceImageLibrary.supportedTextureFormatCount);

                ArTrackedImageManager.referenceLibrary = tmp_RuntimeReferenceImageLibrary;
            }

            ArTrackedImageManager.enabled = true;
2 Likes

ARFoundation & ARKit Imagetracking when image moving ,the prefab object was no smooth follow. How to do smooth follow?

Solved!

Set the Max Number Of Moving ,It’ll working well!

1 Like

Hey Well
How did u get ReferenceImageLibrary work with addressable system ?