Unity Custom Markers

This quick tutorial shows you how to use custom markers with the Unity Plugin.


While the Lego marker is a very good marker for demonstrating Kudan’s image tracking functionality, it’s quite likely that you’ll want your app to use a different marker at some point for that extra bit of personalisation or branding.

Create a ‘.KARMarker’

Unlike the native SDKs, the Unity Plugin can’t just get a raw image file from the assets and load it into the tracker. This is a feature we will be adding to the plugin in the future.

To add a new marker to the Unity plugin, you’ll first need to create a .KARMarker file. See our Kudan AR Toolkit Guide for information on how to do this.

Add your ‘.KARMarker’ to Unity

Once you have your .KARMarker, find select the object with the TrackingMethodMarker script. In the Kudan Sample, this is the MarkerTracking object, which is a child of the Kudan Cameraobject.

In the inspector, at the bottom of the this script, there is a button labelled “Add KARMarker asset”. Click this, search for the KARMarker dataset you created and open it. This will add the set to Unity and create a new Marker asset within the Assets folder.

Load your ‘.KARMarker’ into the Tracker

Now that we have our markers added to the editor, we need to load them into the tracker. To do this, go back to the TrackingMethodMarker script. Open up the list of markers via the drop down arrow, and you’ll see we already have a marker set in Element 0 called DemoMarker (TrackableData). This is the default data set, which contains the lego marker. To use your markers in place of this marker set, simply drag and drop your marker set into the same field, and it will replace the demo marker.

If you want to use your own markers alongside the demo marker, then you’ll have to change the number of entries in the list. Click the Size field, type in the new size you want the list to be, then press enter. This is important: DO NOT CLICK AWAY BEFORE PRESSING ENTER. If you click away, the inspector will not register the change. You must press enter in order to actually change the size of the list. Once you have a larger list, extra entries will be available to you. You can drag and drop your marker sets into these entries, or use the small circle to the right of their respective fields to search your assets for them.

Change the transform driver’s ‘Expected ID’

Now your markers are loaded, but to use them, the MarkerTransformDriver script needs to know which image it’s looking for. This is why you should have made a note of the image’s name(s) when making your marker set. Find this script in your scene. In the Kudan sample, it is attached to the Marker object, which is a child of the Drivers object. Click in the Expected ID field and enter the ID of the image you want to detect.

Once you have your marker set loaded and the correct ID in the transform driver, you should be good to go. Start up your app in play mode or on a device and you’ll be able to detect your new markers.