f111fei / react-native-unity-view

Show an unity view in react native
MIT License
401 stars 102 forks source link

Vuforia datasets don't load #20

Closed Charlynux closed 6 years ago

Charlynux commented 6 years ago

We clone the react-native-unity-demo repository for "POCing around" with Unity + React Native. Wanting to play with some Vuforia, we add an ARCamera and an ImageTarget (with predefined assets). When we build the project in Unity, AR works with no problem, but when we export it then install it on an iOS device, it doesn't work.

The application start, with the camera view (including the Vuforia watermark), but recognition doesn't work. In logs, we found this line : Dataset VuforiaMars_Images could not be loaded and cannot be activated.

I can see the files in UnityExport/Data/Raw/Vuforia, but maybe Vuforia search in an other directory ?

I don't know how to find more debugging informations, so any tip would be appreciated.

Charlynux commented 6 years ago

I fixed it !

During my search, I quickly found informations here. But LoadDatabaseBehaviour doesn't exist anymore in Vuforia 7. By the way, the function AddExternalDatasetSearchDir is still in the documentation. I discover here how to call it in Unity code.

To fix the problem, I add a component "script" on the ARCamera. With the following code :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class DataSetLoadController : MonoBehaviour {

    // Use this for initialization
    void Start () {
        var databaseLoader = DatabaseLoadARController.Instance;
        databaseLoader.AddExternalDatasetSearchDir(Application.dataPath + "/Raw/Vuforia/");
    }

    // Update is called once per frame
    void Update () {

    }
}

Just rebuild the project (Unity + iOS) and it works !