- Sort Posts
- 5 replies
- Last post
Re: How to create Frame Marker at runtime on Unity?
March 4, 2012 - 6:02pm #5
Re: How to create Frame Marker at runtime on Unity?
March 2, 2012 - 1:42pm #4
Ah, if you're trying to call this from a Start method you need to make sure the tracker has had a chance to initialize first. That happens in the QCARBehaviour.Start method. You can use the script ordering feature in Unity 3.5 to make sure you script is called after the rest. Or, you can initialize your markers in the Update method (and guard it to make sure it only happens once).
- Kim
Re: How to create Frame Marker at runtime on Unity?
March 2, 2012 - 4:38am #3
Thanks, Kim.
I tried the code.
but "TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER);" is always returned null.
Can we use this method on Vuforia 1.5 ?
When I tried "tracker = new MarkerTracker()" On Unity Editor, It looks runnning.
but not running on iOS.
Re: How to create Frame Marker at runtime on Unity?
March 1, 2012 - 3:18pm #2
Sorry, that needs to be added to the documentation. Here's a code snippet:
MarkerTracker markerTracker = (MarkerTracker)TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER); int markerId = 0; // between 0 and 511 MarkerBehaviour mb = markerTracker.CreateMarker(markerId, "marker" + markerId, 100); if (mb != null) { mb.gameObject.AddComponent<DefaultTrackableEventHandler>(); GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.parent = mb.transform; cube.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); cube.transform.localPosition = new Vector3(0.0f, 0.25f, 0.0f); }
- Kim
I'm on Unity 5.0.2 and Vuforia 4.2.3 and this didn't work for me. No matter if I use InitTracker or GetTracker, it always returns null.
Also I'm scripting in C# Script.
I call all of this in Start() and changed the order, so QCARBehaviour runs before Default Time and my Script after Default Time. But it's still null. I couldn't find much help, hope somebody has an idea of what's wrong.
(I do realize, that my versions are like 3 years newer, but it's the same problem.)