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.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[Helpe] How to load ReferenceImageLibrary from assetbundle or addressable

Discussion in 'AR' started by WellC, Sep 14, 2019.

  1. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    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:
    Code (CSharp):
    1.  [General] No resource group with name "ReferenceImageLibrary_F9826AB7-B00D-45C3-BB5E-C1090EB7CF4F" found
    2. 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.
    3.   at UnityEngine.XR.ARKit.ARKitImageTrackingSubsystem+Provider.set_imageLibrary (UnityEngine.XR.ARSubsystems.XRReferenceImageLibrary value) [0x00000] in <00000000000000000000000000000000>:0
    4.   at UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem.Start () [0x00000] in <00000000000000000000000000000000>:0
    5.   at UnityEngine.XR.ARFoundation.SubsystemLifecycleManager`2[TSubsystem,TSubsystemDescriptor].OnEnable () [0x00000] in <00000000000000000000000000000000>:0
    6.   at UnityEngine.Behaviour.set_enabled (System.Boolean value) [0x00000] in <00000000000000000000000000000000>:0
    7.   at ARPropertiesManager.<StartImageTracking>b__23_0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] _handle) [0x00000] in <00000000000000000000000000000000>:0
    8.   at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
    9.   at DelegateList`1[T].Invoke (T res) [0x00000] in <00000000000000000000000000000000>:0
    10.   at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
    11.   at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].Complete (TObject result, System.Boolean success, System.String errorMsg) [0x00000] in <00000000000000000000000000000000>:0
    12.   at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0
    13.   at UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[TObject].ProviderCompleted[T] (T result, System.Boolean status, System.Exception e) [0x00000] in <00000000000000000000000000000000>:0
    14.   at UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider+InternalOp.ActionComplete (UnityEngine.AsyncOperation obj) [0x00000] in <00000000000000000000000000000000>:0
    15.   at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
    16.   at UnityEngine.AsyncOperation.InvokeCompletionEvent () [0x00000] in <00000000000000000000000000000000>:0
     
    Last edited: Sep 14, 2019
  2. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48

    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.

    Code (CSharp):
    1. MutableRuntimeReferenceImageLibrary tmp_RuntimeReferenceImageLibrary =
    2.                 ArTrackedImageManager.CreateRuntimeLibrary() as MutableRuntimeReferenceImageLibrary;
    3.             foreach (XRReferenceImage tmp_ReferenceImage in _handle.Result)
    4.             {
    5.                 JobHandle tmp_JobHandle = tmp_RuntimeReferenceImageLibrary.ScheduleAddImageJob(
    6.                     tmp_ReferenceImage.texture,
    7.                     tmp_ReferenceImage.name, tmp_ReferenceImage.width);
    8.                 tmp_JobHandle.Complete();
    9.             }
    10.  
    11.             if (tmp_RuntimeReferenceImageLibrary != null)
    12.             {
    13.                 Debug.Log("tmp_RuntimeReferenceImageLibrary: " + tmp_RuntimeReferenceImageLibrary.count);
    14.                 Debug.Log(
    15.                     "supportedTextureFormatCount: " + tmp_RuntimeReferenceImageLibrary.supportedTextureFormatCount);
    16.  
    17.                 ArTrackedImageManager.referenceLibrary = tmp_RuntimeReferenceImageLibrary;
    18.             }
    19.  
    20.             ArTrackedImageManager.enabled = true;
     
    mtalbott and Blarp like this.
  3. WellC

    WellC

    Joined:
    Mar 2, 2015
    Posts:
    48
    ARFoundation & ARKit Imagetracking when image moving ,the prefab object was no smooth follow. How to do smooth follow?


    Solved!

    upload_2019-9-18_15-11-16.png


    Set the Max Number Of Moving ,It'll working well!
     
    Last edited: Sep 18, 2019
    AlexisAG likes this.
  4. zicas2000

    zicas2000

    Joined:
    Feb 11, 2018
    Posts:
    2
    Hey Well
    How did u get ReferenceImageLibrary work with addressable system ?