Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Resolved Remove canvas on TrackingStateCondition

Discussion in 'Unity MARS' started by Ricardotlpz, Jul 14, 2021.

  1. Ricardotlpz

    Ricardotlpz

    Joined:
    May 17, 2021
    Posts:
    63
    Hey! I was diving into the documentation but can't seem to find enough info on how to code the following:

    1. AR session is initialized with a canvas that shows a box to fit an image marker
    2. When the image marker is tracked, remove the box to fit the image marker

    I'm guessing it's fairly simple with something like if(TrackingStateCondition = true), do X, but can't seem to find how to call that specific thing.
     
  2. Jono_Unity

    Jono_Unity

    Unity Technologies

    Joined:
    Apr 5, 2016
    Posts:
    18
    Hey @Ricardotlpz! This is super quick to do using a 'Match Action' on your image marker proxy and doesn't require writing any code. Set up your UI canvas with the marker instructions, and then on the marker proxy, add a 'Match Action', then use the 'Add Event' button in that component to add a 'On Match Acquire' event, connect your canvas, and set the dropdown to GameObject.SetActive, with the checkbox to 'false'. So your proxy will look something like this:
    upload_2021-7-14_14-30-40.png
    Full editor context:
    upload_2021-7-14_14-38-50.png

    You'll see that I've also added a simulated image marker into my simulation scene, so I can test this locally. You can do that using the MARS Panel (Window > MARS > MARS Panel), and pick 'Synthetic Image Marker' there, and make sure to set that marker and your marker condition up to use the same image.

    I attached a package containing the scene+asset I put together for the screenshots.

    Does that do what you're looking for?
     

    Attached Files:

    Ricardotlpz and jmunozarUTech like this.
  3. Ricardotlpz

    Ricardotlpz

    Joined:
    May 17, 2021
    Posts:
    63
    YES! This was exactly what I was looking for! Thank you so much.
     
    Jono_Unity likes this.
  4. Jono_Unity

    Jono_Unity

    Unity Technologies

    Joined:
    Apr 5, 2016
    Posts:
    18
    Awesome, you're welcome, keep it coming!
     
    Ricardotlpz likes this.