Log in or register to post comments

Can we use ARCore unity SDK components with Vuforia 7.2 ?

August 1, 2018 - 2:58am #1

Hi,

In a Unity Project, I am using both ARKit and Vuforia in two different scenes, using ARKit sdk for Unity and Vuforia 7.1.35 in Unity 2018.1.6, and it works.

Now, I want to use ARCore. I updated Vuforia to 7.2, but I don't figure out how to use the components from ARCore SDK (plane detection, point cloud visualizer, CloudAnchor, etc...) and Vuforia in only one project. In Player Settings/XR Settings, I can only check "vuforia augmented reality supported" or "ARCore supported" but not both. I tried to import arcore Unity SDK package (v1.3.0) in my Unity Project with Vuforia supported, but I can't build the HelloAR scene from ARCore sdk.

 

I know Vuforia 7.2 supports ARCore, but here is my question : Can we have access to ARCore functionalities through Vuforia ? Can we use Detected Plane Generator, Environmental Light and Pointcloud Visualizer provided by ARCore sdk along with Vuforia 7.2 ? If so, how can we combine both ?

Thanks in advance.

PS : sorry if I made english mistakes.

Can we use ARCore unity SDK components with Vuforia 7.2 ?

August 8, 2018 - 2:15am #5

Hi,

I did more tests since last time and I figured out that what I did for combining ARCore sdk and Vuforia 7.2 in only one Unity Project does not work on Android 8.0 devices.

If you check ARCore supported and Vuforia supported in Player/XR Settings, on an Android 8 devices, you will have a "Vuforia Initialization Error". However, if you build a first time with only Vuforia supported checked, launch the app, and then rebuild with both checked, you won't have the Init Error and everything will work as expected. I think this is because the initialization works the first time (without "ARCore supported" checked), and store on the device an information telling "initialization ok", then when we build&run a second time, this time with "ARCore supported" checked  in addition to "Vuforia supported", the app retrieves this information on the device and the initialization works. But if you remove the app from your smartphone, and build&run again with both ARCore and Vuforia supported, you will have again the initialization error from Vuforia.

Unfortunately this workaround cannot be used with final users because only the dev can build a first time with only Vuforia supported and a second time with both ARCore and Vuforia.

So the behaviour is not the same on Android 7 and Android 8 (on Android 7, it works with ARCore and Vuforia supported even at the first installation just by changing the AndroidManifest.xml as I specified in a previous post).

 

EDIT : Finally, I found a solution !

It was an error with permissions so I checked AndroidManifest.xml generated by unity in Your_Unity_Project/Temp/StagingArea folder.

And I found this strange line : <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />

Unity add this line when you check ARCore supported, I don't know why. Because of this, the user couldn't allow the app to use camera, resulting in Vuforia init error.

To fix it, add the line above in your AndroidManifest.xml, and change android:value="true" by android:value="false", then it will work with Vuforia and ARCore both checked in XR Settings for Android 8.0 !

Can we use ARCore unity SDK components with Vuforia 7.2 ?

August 3, 2018 - 6:44am #4

Hi,

I didn't try to use ARCore and Vuforia in only one scene yet, but I would be surprised if it works.

However, I tried ARKit and Vuforia in one scene and it worked but I had to enable only one of them at the same time. I made a script to switch between Vuforia or ARKit in a single scene, with these functions :

    

public GameObject goARKit;

public GameObject goVuforia;

public void SwitchToVuforia()

    {

            UnityARSessionNativeInterface.GetARSessionNativeInterface().Pause();

            goVuforia.SetActive(true);

            goARKit.SetActive(false);

            ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

            objectTracker.Start();

    }

 

    public void SwitchToARKit()

    {

            goVuforia.SetActive(false);

            goARKit.SetActive(true);

            ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

            objectTracker.Stop();

            UnityARSessionNativeInterface.GetARSessionNativeInterface().Run();

    }

 

goARKit and goVuforia are empty GameObjects in my scene, which are parents of every ARKit or Vuforia objects respectively (as children of goVuforia, I have ARCamera and ImageTarget, and as children of goARKit, I have ARCameraManager, ARKit Camera, PointCloudParticleExample and UnityARGeneratePlanes).

It works but the camera freezes for some seconds when you switch from one to the other, so you should add a loading screen.

 

Can we use ARCore unity SDK components with Vuforia 7.2 ?

August 3, 2018 - 6:27am #3

Interesting. But I guess this only works if you use two separate scenes, right? I was looking for a way to use ARKit in combination with Vuforia, but in the very same scene (ARKit for World Mapping, Vuforia for MultiTarget tracking). I was hoping there was a way to access the underlying native interfaces if Vuforia was running in Fusion mode.

Can we use ARCore unity SDK components with Vuforia 7.2 ?

August 2, 2018 - 6:57am #2

Finally, I succeeded to combine both ARCore sdk and Vuforia 7.2.24 in the same Unity Project.

Here is what I did for those who are interested :

1) In Unity 2018.1.6, update Vuforia to 7.2.24

2) Import ARCore unitypackage 1.3.0

3) In PlayerSettings/XR Settings, check both "ARCore supported" and "Vuforia augmented reality supported" even if it is not recommanded by Unity.

4) Make 3 scenes : a main scene (menu), a Vuforia scene and an ARCore scene. The main scene has 2 buttons, one to load Vuforia scene and one to load ARCore scene. The Vuforia scene is a basic scene with ARCamera and a image target with a primitive cube in it. The ARCore scene is the HelloAR scene from ARCore package. Both ARCore scene and Vuforia scene have a button "Back" to load the main scene.

5) Build and run on Android. During the build, I had an issue with AndroidManifest. I had to get the default AndroidManifest.xml and add these lines just before <activity> node to correct the issue :

<meta-data tools:replace="android:value" android:name="com.google.ar.core" android:value="required"/>

6) Place this new AndroidManifest.xml in Assets/Plugins/Android.

7) Build and run : it worked !

 

I don't know why it is not recommended to check both ARCore and Vuforia in XR Settings but in my case it works. Maybe it can cause some troubles with specific functionalities or on some devices. If someone have more informations about this, I'm interested.

I didn't follow the instructions here https://library.vuforia.com/articles/Solution/arcore-with-vuforia.html because when I added the .aar from ARCore in Plugins/Android and check ARCore supported, I had build errors. And if I don't check ARCore supported, the HelloAR scene from ARCore doesn't work as expected (black screen, no camera feed). So the only solution I found was to check both ARCore and Vuforia supported in XR Settings.

Log in or register to post comments