{"id":279,"date":"2018-10-03T17:16:50","date_gmt":"2018-10-03T17:16:50","guid":{"rendered":"https:\/\/www.xlsoft.com\/doc\/kudan\/?page_id=279"},"modified":"2018-10-18T21:12:11","modified_gmt":"2018-10-18T21:12:11","slug":"unity-custom-markers","status":"publish","type":"page","link":"https:\/\/www.xlsoft.com\/doc\/kudan\/unity-custom-markers\/","title":{"rendered":"Unity Custom Markers"},"content":{"rendered":"<p>This quick tutorial shows you how to use custom markers with the Unity Plugin.<\/p>\n<div class=\"excerpt\">\n<hr \/>\n<div class=\"magic-block-textarea\">\n<p>While the Lego marker is a very good marker for demonstrating Kudan&#8217;s image tracking functionality, it&#8217;s quite likely that you&#8217;ll want your app to use a different marker at some point for that extra bit of personalisation or branding.<\/p>\n<\/div>\n<div class=\"magic-block-api-header\">\n<div id=\"section-create-a-karmarker\" class=\"anchor waypoint\"><\/div>\n<h1 class=\"header-scroll is-api-header\">Create a &#8216;.KARMarker&#8217;<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>Unlike the native SDKs, the Unity Plugin can&#8217;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.<\/p>\n<p>To add a new marker to the Unity plugin, you&#8217;ll first need to create a\u00a0<code>.KARMarker<\/code>\u00a0file. See our\u00a0<a class=\"doc-link\" href=\"https:\/\/www.xlsoft.com\/doc\/kudan\/kudan-ar-toolkit-guide\/\" data-sidebar=\"kudan-ar-toolkit-guide\">Kudan AR Toolkit Guide<\/a>\u00a0for information on how to do this.<\/p>\n<\/div>\n<div class=\"magic-block-api-header\">\n<div id=\"section-add-your-karmarker-to-unity\" class=\"anchor waypoint\"><\/div>\n<h1 class=\"header-scroll is-api-header\">Add your &#8216;.KARMarker&#8217; to Unity<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>Once you have your\u00a0<code>.KARMarker<\/code>, find select the object with the\u00a0<code>TrackingMethodMarker<\/code>\u00a0script. In the Kudan Sample, this is the\u00a0<code>MarkerTracking<\/code>\u00a0object, which is a child of the\u00a0<code>Kudan Camera<\/code>object.<\/p>\n<p>In the inspector, at the bottom of the this script, there is a button labelled \u201cAdd KARMarker asset\u201d. 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.<\/p>\n<\/div>\n<div class=\"magic-block-api-header\">\n<div id=\"section-load-your-karmarker-into-the-tracker\" class=\"anchor waypoint\"><\/div>\n<h1 class=\"header-scroll is-api-header\">Load your &#8216;.KARMarker&#8217; into the Tracker<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>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\u00a0<code>TrackingMethodMarker<\/code>\u00a0script. Open up the list of markers via the drop down arrow, and you&#8217;ll see we already have a marker set in\u00a0<em>Element 0<\/em>\u00a0called\u00a0<code>DemoMarker (TrackableData)<\/code>. 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.<\/p>\n<p>If you want to use your own markers alongside the demo marker, then you&#8217;ll have to change the number of entries in the list. Click the\u00a0<code>Size<\/code>\u00a0field, type in the new size you want the list to be, then press enter. This is important:\u00a0<em>DO NOT CLICK AWAY BEFORE PRESSING ENTER<\/em>. 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.<\/p>\n<\/div>\n<div class=\"magic-block-api-header\">\n<div id=\"section-change-the-transform-drivers-expected-id\" class=\"anchor waypoint\"><\/div>\n<h1 class=\"header-scroll is-api-header\">Change the transform driver&#8217;s &#8216;Expected ID&#8217;<\/h1>\n<\/div>\n<div class=\"magic-block-textarea\">\n<p>Now your markers are loaded, but to use them, the\u00a0<code>MarkerTransformDriver<\/code>\u00a0script needs to know which image it&#8217;s looking for. This is why you should have made a note of the image&#8217;s name(s) when making your marker set. Find this script in your scene. In the Kudan sample, it is attached to the\u00a0<code>Marker<\/code>\u00a0object, which is a child of the\u00a0<code>Drivers<\/code>\u00a0object. Click in the\u00a0<code>Expected ID<\/code>\u00a0field and enter the ID of the image you want to detect.<\/p>\n<p>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&#8217;ll be able to detect your new markers.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s image tracking functionality, it&#8217;s quite likely that you&#8217;ll want your app to use a different marker at some point for that extra bit of personalisation or branding. Create a &#8230; <a title=\"Unity Custom Markers\" class=\"read-more\" href=\"https:\/\/www.xlsoft.com\/doc\/kudan\/unity-custom-markers\/\">Read more<span class=\"screen-reader-text\">Unity Custom Markers<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"bekko_page_header":""},"_links":{"self":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages\/279"}],"collection":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":8,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages\/279\/revisions"}],"predecessor-version":[{"id":1428,"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/pages\/279\/revisions\/1428"}],"wp:attachment":[{"href":"https:\/\/www.xlsoft.com\/doc\/kudan\/wp-json\/wp\/v2\/media?parent=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}