AR Track Trigger
Hi MaxST Team,
I'm new to AR and currently developing a simple app showcasing some 3D models.
I've made a focus frame on its on layer which I want to be hidden by changing the camera culling mask when the target is detected. However I am unable to figure out how to get it done.
Unfortunately I have minimal scripting knowledge and I am mostly using PlayMaker FSM to do the functions. So by guess work it has to do with
TrackerManager.GetInstance().LoadTrackerData();
Thanks for helping.
Hello
When you control augmented content, you need to change the renderer of the registered object. (Unless you are an experienced user, we recommend that you do not change camera masking as much as possible.)
The SDK sample provided by us can be tested without changing the script. Below is a description of the example.
https://developer.maxst.com/MD/doc/unity/ex/image
Thank you.
- MAXST support team
Hi,
I think you've misunderstood my question. I'm able to make the image target work no problem. The thing I want to achieve is when the imagetarget is detected and the model renders, certain element in the Canvas hides/deactivates.
Say i.e. you have a start screenwith some buttons/logo on top corner or so, and when scanning an imagetaget, it detects and the model appears and at the same time the start screen will be gone.
Thus I believe I need to be able to read imagetarget detection and then call a function to hide/deactivate the canvas.
Thank you.
We're sorry for making you wait.
We've understood your intention finally and it may look like about unity's own function.
Just deactivate UI object (you mentioned it 'focus frame') by calling FocusFrame.gameobject.SetActive(false) when target detected and FocusFrame.gameobject.SetActive(true) when target lost.
Please don't change camera's culling parameter, just change gameobject's state instead.
Thanks
- Maxst support team
Hi,
Thanks for replying. Almost there. As you suggested I'm using activate/deactivate method instead of culling mask but I'm still missing the step.
I need to create a trigger that reads the target detection, then calls the FocusFrame.gamebject.SetActive(false). The trigger is what's missing.
Thanks
Please refer link below
https://developer.maxst.com/MD/doc/unity/ex/image#using-the-tracking-information
The result of GetCount function can be that trigger.
Thanks.
- Maxst support team
Hi Maxst Team,
Thank you for your help! Work wonders!! I've edited the code
Added public GameObject UIElement; at the beginning so I can assign gameobject
Then under
TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();
TrackingResult trackingResult = state.GetTrackingResult();
UIElement.SetActive (true); //Custom - Focus Frame Active
for (int i = 0; i < trackingResult.GetCount(); i++)
{
Trackable trackable = trackingResult.GetTrackable(i);
imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
trackable.GetId(), trackable.GetName(), trackable.GetPose());
UIElement.SetActive (false); //Custom - Disable Focus Frame when Tracking Succeed
}
}
Ideally I'd love to create a new external script to call GetCount trigger from ImageTrackerSample but I have no clue how, since I can't scripting. However, thank you for you help :D
Hi,
The solution that you have found are almost correct.
But we recommend to call UIElement.SetActive just one time by using trackingResult.GetCount().
Please refer to code snippets below.
if (trackingResult.GetCount() == 0) {
UIElement.SetActive (true);
return;
} else {
UIElement.SetActive (false);
}
for ( ) {
...
}
Because calling UIElement.SetActive (false) repeatedly in for loop is overhead anyway.
Thanks
- Maxst support team
Hi,
Awesome! Made changes accordingly. Thank you