Log in or register to post comments

Vuforia 5 Cloud with Unity

February 26, 2016 - 2:33am #1

Hello everyone,

 

  I' am new with vuforia and i have some problems connecting Vuforia 5 Cloud with Unity. I followed the tutorial here: https://developer.vuforia.com/library/articles/Solution/How-To-Create-a-Simple-Cloud-Recognition-App-in-Unity  but it does not work. Do i need to have two separate scripts (SimpleCloudHandler and ICloudRecoEventHandler) in order to work this tutorial? I have some errors and i do not know how to fix them. Is there any other tutorial or video with Vuforia 5?

 

Thank you in advance

:)

Vuforia 5 Cloud with Unity

March 24, 2016 - 4:35am #3

The script should be like this:

 

<pre class="brush: lang">

using UnityEngine;
using System.Collections;
 
namespace Vuforia
{
public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler 
{
 
private CloudRecoBehaviour mCloudRecoBehaviour;
private bool mIsScanning = false;
private string mTargetMetadata = "";
 
 
// Use this for initialization
void Start () 
{
mCloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
if (mCloudRecoBehaviour)
{
mCloudRecoBehaviour.RegisterEventHandler(this);
}
 
WWW www = new WWW(url);
StartCoroutine(WaitForRequest(www));
 
}
 
 
IEnumerator WaitForRequest(WWW www)
{
yield return www;
// check for errors
if (www.error == null)
{
//GUI.Box (new Rect(100,300,200,50), "From Database: " + www.data);
Debug.Log("WWW Ok!: " + www.data);
} else {
Debug.Log("WWW Error: "+ www.error);
}    
}
 
 
public void OnInitialized() 
{
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
ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
tracker.TargetFinder.ClearTrackables(false);
}
}
 
// Here we handle a cloud target recognition event
public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) 
{
// do something with the target metadata
mTargetMetadata = targetSearchResult.MetaData;
// stop the target finder (i.e. stop scanning the cloud)
mCloudRecoBehaviour.CloudRecoEnabled = false;
}
 
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;
}
}
}
 
}
}

 

</pre>

Vuforia 5 Cloud with Unity

March 3, 2016 - 2:39am #2

Does anyone know about a sample ? what files should be modified in order to make my app work? please help :(

Log in or register to post comments