EDITED
I changed my Unity version to
2018.3.8f1
and Vuforia version to8.0.10
and it worked. But anyone knows how to work in the newest version?
I am following this tutorial to implement Cloud Reco in Unity.
Error in my SimpleCloudHandler.cs
script:
error CS0246: The type or namespace name 'ICloudRecoEventHandler' could not be found (are you missing a using directive or an assembly reference?)
My Unity version is 2018.3.14f1
My Vuforia version is 8.1.7
My code following the tutorial:
using Vuforia;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler
{
private CloudRecoBehaviour mCloudRecoBehaviour;
private bool mIsScanning = false;
private string mTargetMetadata = "";
public ImageTargetBehaviour ImageTargetTemplate;
public void OnInitialized(TargetFinder targetFinder) {
Debug.Log ("Cloud Reco initialized");
}
public void OnInitError(TargetFinder.InitState initError) {
Debug.Log ("Cloud Reco init error " + initError.ToString());
}
public void OnUpdateError(TargetFinder.UpdateState updateError) {
Debug.Log ("Cloud Reco update error " + updateError.ToString());
}
public void OnStateChanged(bool scanning) {
mIsScanning = scanning;
if (scanning)
{
// clear all known trackables
var tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
tracker.TargetFinder.ClearTrackables(false);
}
}
// Here we handle a cloud target recognition event
public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) {
TargetFinder.CloudRecoSearchResult cloudRecoSearchResult =
(TargetFinder.CloudRecoSearchResult)targetSearchResult;
// do something with the target metadata
mTargetMetadata = cloudRecoSearchResult.MetaData;
// stop the target finder (i.e. stop scanning the cloud)
mCloudRecoBehaviour.CloudRecoEnabled = false;
// Build augmentation based on target
if (ImageTargetTemplate) {
// enable the new result with the same ImageTargetBehaviour:
ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
ImageTargetBehaviour imageTargetBehaviour =
(ImageTargetBehaviour)tracker.TargetFinder.EnableTracking(
targetSearchResult, ImageTargetTemplate.gameObject);
}
}
void OnGUI() {
// Display current 'scanning' status
GUI.Box (new Rect(100,100,200,50), mIsScanning ? "Scanning" : "Not scanning");
// Display metadata of latest detected cloud-target
GUI.Box (new Rect(100,200,200,50), "Metadata: " + mTargetMetadata);
// If not scanning, show button
// so that user can restart cloud scanning
if (!mIsScanning) {
if (GUI.Button(new Rect(100,300,200,50), "Restart Scanning")) {
// Restart TargetFinder
mCloudRecoBehaviour.CloudRecoEnabled = true;
}
}
}
// Start is called before the first frame update
void Start()
{
mCloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
if (mCloudRecoBehaviour){
mCloudRecoBehaviour.RegisterEventHandler(this);
}
}
// Update is called once per frame
void Update()
{
}
}