Search code examples
c#unity-game-enginevuforiaunity3d-editorunity3d-terrain

Errors when upgrading Vuforia in Unity from version 9 to version 10


The type or namespace name 'SmartTerrain' could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name 'PositionalDeviceTracker' could not be found (are you missing a using directive or an assembly reference?)

These errors weren't in version 9 but in version 10 they are affecting project flow please help me

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Vuforia;
public class ARManager : MonoBehaviour
{
    public PlaneFinderBehaviour finder;
    SmartTerrain smartTerrain;
    PositionalDeviceTracker positionalDeviceTracker;
    ...........

Solution

  • tl;dr: These types don't exist anymore since they are not needed anymore.


    I would start at Vuforia - Migration Guide for Vuforia Engine Unity Projects.

    In general for any software library it is not unlikely that things and the API change between major versions - indeed such a breaking change is one of the main reasons to release a new major version at all!

    This page documents the changes between Vuforia Engine version 9.8 and version 10 as the API has fundamentally changed. Use this overview to learn about the native changes and for migrating your existing projects to the new API.

    So read up what to use instead or what changed in the API => what you have to change in your code to adopt - or stick to the version 9 if it worked for you and you don't need the newest features ;)

    In your specific cases

    Ground Plane

    Some more advanced Ground Plane APIs have changed. Apps that were using not just the game objects above, but additional runtime scripting APIs might have to be adapted.

    The Smart Terrain Tracker has been removed. It no longer needs to be managed manually. Consequently, checking for Ground Plane support at runtime has changed.

    Vuforia Engine 9.8:

    SmartTerrain smartTerrain = TrackerManager.Instance.GetTracker<SmartTerrain>();
    if (smartTerrain == null)
        Debug.Log("SmartTerrain returned null. GroundPlane not supported on this device.");
    

    Vuforia Engine 10.0:

    if (VuforiaBehaviour.Instance.World.AnchorsSupported == false)
        Debug.Log("GroundPlane not supported on this device.");
    

    and

    Device Tracking

    Access to device tracking has been simplified and is now available centrally through VuforiaBehaviour.Instance.DevicePoseBehaviour.

    Resetting Device Tracking

    Vuforia Engine 9.8:

    var deviceTracker = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();
    deviceTracker.Reset();
    

    Vuforia Engine 10.0:

    VuforiaBehaviour.Instance.DevicePoseBehaviour.Reset();
    

    Registering to updates to the device tracking status

    Vuforia Engine 9.8:

    private void Start()
    {
        DeviceTrackerARController.Instance.RegisterDevicePoseStatusChangedCallback(OnDevicePoseStatusChanged);
    }
    void OnDevicePoseStatusChanged(Vuforia.TrackableBehaviour.Status status, Vuforia.TrackableBehaviour.StatusInfo statusInfo)
    {
        Debug.Log("OnDevicePoseStatusChanged(" + status + ", " + statusInfo + ")");
    
        …
    }
    

    Vuforia Engine 10.0:

    private void Start()
    {
        VuforiaBehaviour.Instance.DevicePoseBehaviour.OnTargetStatusChanged += OnDevicePoseStatusChanged; 
    }
    void OnDevicePoseStatusChanged(ObserverBehaviour behaviour, TargetStatus targetStatus)
    {
        Debug.Log("OnDevicePoseStatusChanged(" + targetStatus.Status + ", " + targetStatus.StatusInfo + ")");
    }
    

    Enabling and disabling Device Tracking

    Vuforia Engine 9.8:

    public void ToggleDeviceTracking(bool enableDeviceTracking)
    {
        var posDeviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();
        if (enableDeviceTracking)
            posDeviceTracker.Start();
        else
            posDeviceTracker.Stop();
    }
    

    Vuforia Engine 10.0:

    public void ToggleDeviceTracking(bool enableDeviceTracking)
    {
        VuforiaBehaviour.Instance.DevicePoseBehaviour.enabled = enableDeviceTracking; 
        
    }