no extension method `GetTracker' - Vuforia + Unity
I have been following various tutorials on vuforia on building a recognition app, however I had a problem with one part of the code that I can't seem to fix.
My code gives me an error like this:
Type UnityEngine.GameObject' does not contain a definition for
GetTracker' and no extension method GetTracker' of type
UnityEngine.GameObject' could be found.
Is there any reason the GetTracker doesn't work? I'm new to this coding thing and I don't know what could be the problem.
Here is the whole code, in case maybe I missed something.
public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler {
private CloudRecoBehaviour mCloudRecoBehaviour;
private bool mIsScanning = false;
private string mTargetMetadata = "";
private ImageTracker mImageTracker;
public TrackerManager mTrackerManager;
public ImageTargetBehaviour ImageTargetTemplate;
// Use this for initialization
void Start ()
{
// register this event handler at the cloud reco behaviour
mCloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
if (mCloudRecoBehaviour)
{
mCloudRecoBehaviour.RegisterEventHandler(this);
}
}
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 class ImageTracker
{
}
public class TrackerManager
{
public GameObject Instance;
}
public void OnStateChanged(bool scanning) {
mIsScanning = scanning;
if (scanning)
{
// clear all known trackables
mImageTracker = mTrackerManager.Instance.GetTracker<ImageTracker>();
//ImageTracker.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;
if (ImageTargetTemplate) {
// enable the new result with the same ImageTargetBehaviour:
ObjectTracker tracker = mTrackerManager.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;
}
}
}
}
Answer by anakin0225 · Oct 08, 2017 at 01:13 PM
try "using UnityEngine;" instead of "using UnityEngine.GameObject;"
Your answer
Follow this Question
Related Questions
Image Target Recognizer 0 Answers
[Unity Vuforia] Rotating an object with mouse drag. 0 Answers
Detecting touch on a 3d model imported in Unity for an AR application using Vuforia 0 Answers
Is there any way to combine text recognition with extended tracking in unity using vufria's sdk? 0 Answers
jump a virtual element on the target 0 Answers