Anyone know if there's a way you can create frame targets dynamically in Unity3D? I was hoping I could instantiate a frame target prefab like 50 times and increment the marker ID for each one. I've tried doing that thru script but it doesn't work. I don't get any errors but it runs with strange side-effects that suggest that when one marker is detected it triggers the detection of all the clones. Is there any way of doing this during runtime or do I have to manually put 50 frame targets into the scene?
creating frame targets dynamically
Dynamic FrameMarker creation, and destruction, is a feature of the current release. This script demonstrates how to create and destroy FrameMarkers at runtime..
public class MarkerController : MonoBehaviour
private int mNextMarkerID = 0;
MarkerTracker markerTracker = (MarkerTracker)TrackerManager.Instance.GetTracker(Tracker.Type.MARKER_TRACKER);
GUILayout.BeginArea( new Rect( 25, 100, 300, 500 ) );
if (GUILayout.Button("Create Marker"))
MarkerBehaviour mb = markerTracker.CreateMarker(mNextMarkerID, "marker" + mNextMarkerID, 100);
if (mb != null)
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);
if (GUILayout.Button("Destroy Last Marker"))
for (int i = 0; i < markerTracker.GetNumMarkers(); i++)
MarkerBehaviour marker = markerTracker.GetMarker(i);
if (marker.MarkerID == mNextMarkerID - 1)
if (markerTracker.DestroyMarker(marker, true))
if (GUILayout.Button( "Destroy All Markers"))
mNextMarkerID = 0;
Are you sure you want to delete this message?
Are you sure you want to delete this conversation?