Log in or register to post comments

Show onscreen UI Button as Augmented Reality

November 20, 2015 - 9:34pm #1

Hi, I am new to Unity and Vuforia.  Please forgive me if I've posted this in the wrong forum.  

I was able to set up an ARCamera and ImageTarget with a child GameObject cube. When I scan my marker with my iPad, I can see the cube hovering over my marker. Great.

Now, I am trying to get the cube to become a clickable button so I tried using a UI Button. However, creating any UI object means that it comes with a UI Canvas as well. So, I want to be able to scan the marker and have the button show up but that is not working. The button is simply just there on the screen regardless of whether or not I scan over the marker. 

What should my hierarchy look like?

ARCamera
-> Camera

ImageTarget
-> Canvas
->-> Button
->->-> Text

Or should it be:

ARCamera
-> Camera

Canvas
-> ImageTarget
->-> Button
->->->Text

What do I do with two ImageTargets? Should I use the first hierarchy or second?

Finally, what should my canvas Render Mode be? I currently have it as "Screen Space - Overlay." I tried "Screen Space - Camera" but it didn't really make that much of a difference. The buttons still did not show up when scanning the marker.

Show onscreen UI Button as Augmented Reality

August 2, 2017 - 1:28am #5

This solution works perfectly as I have tested it on Unity 5.6 using vuforia.

Thanks for sharing the solution. Cheers!

Show onscreen UI Button as Augmented Reality

December 1, 2015 - 5:55pm #4

You might need to adjust the scale of the ImageTarget and Canvas to get them to be closer in size. You should position the Canvas with respect to the ImageTarget prior to parenting it. You can use a single EventSystem and it can be placed outside the ImageTarget hierarchy.

http://unity3d.com/learn/tutorials/topics/user-interface-ui

 

Show onscreen UI Button as Augmented Reality

November 27, 2015 - 1:37pm #3

Thank you for your reply.  I've modified my hierarchy to look like this:

ImageTarget
-- Empty Game Object
-----Canvas
-------UIButton
---------Text

Canvas is now in world space as well.  

But now the button, marker, and text disappears from the editor screen.  I've attached a screenshot as to how it looks like now.  

In a big picture sense, this is all I'm trying to do.  I want to scan around a room with an iPad and then when it sees this marker, it will have a touchable/tap-able button (or object).  Once tapped, it opens up a dialog window with information about the marker, etc.  

Maybe this can be achieved without having to mess with Canvases or UI objects.  If it can just be done with GameObjects, ImageTargets and a script to make the GameObject touchable and have it open into a dialog box, then I am totally open to those suggestions too.  Please just point me on the right path.  

Any help would be greatly appreciated!  Thank you.  

Show onscreen UI Button as Augmented Reality

November 23, 2015 - 4:11pm #2

You need to set the Canvas to World Space before parenting it to the ImageTarget prefab.

ImageTarget
-- Empty Game Object (preserves correct scaling)
---- Canvas
------ Canvas Element

 

Log in or register to post comments