private void Awake()
    {
#if UNITY_ANDROID
        bool driverLibrarySet = false;
        driverLibrarySet = VuforiaUnity.SetDriverLibrary("libUVCDriver.so");

        if (driverLibrarySet)
        {
            // Load your applications scene here
            // InitAndLoadScene(VUFORIA_DRIVER_CAMERA_SCENE_INDEX);

            // The application needs to ask for USB permissions to run the USB camera
            // this is done after the driver is loaded. We call a method in the UVC driver
            // Java code to request permissions, passing in the Unity app's activity.
            AndroidJavaClass  unityJC       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject unityActivity = unityJC.GetStatic <AndroidJavaObject>("currentActivity");

            AndroidJavaClass usbControllerJC = new AndroidJavaClass("com.vuforia.samples.uvcDriver.USBController");
            usbControllerJC.CallStatic("requestUSBPermission", unityActivity);
        }
        else
        {
            Debug.Log("Failed to initialize the UVC driver - defaulting to the standard scene");

            // Fall back to the in-built camera
        }
#endif
    }
예제 #2
0
    private void Awake()
    {
        if (ConfigureDriver)
        {
            _userData = new DriverUserData
            {
                cameraName = CameraName
            };

            _userDataPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DriverUserData)));
            Marshal.StructureToPtr(_userData, _userDataPointer, false);
        }
        else
        {
            _userDataPointer = IntPtr.Zero;
        }

        var isDriverLibrarySet = VuforiaUnity.SetDriverLibrary(LibraryName, _userDataPointer);

        if (!isDriverLibrarySet)
        {
            Debug.LogError("Failed to set driver library");
        }

        VuforiaRuntime.Instance.InitVuforia();
    }
예제 #3
0
    void Awake()
    {
#if UNITY_WSA && !UNITY_EDITOR
        string filePath = Application.streamingAssetsPath.Replace("/", "\\");

        userData = new FileDriverUserData()
        {
            sequenceDirectoryAbsolutePath = filePath
        };

        userDataPrt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FileDriverUserData)));
        Marshal.StructureToPtr(userData, userDataPrt, false);


        VuforiaUnity.SetDriverLibrary("FileDriver.dll", userDataPrt);
#endif
        VuforiaRuntime.Instance.InitVuforia();
    }