Just start creating an AR app using Vuforia and unity.
Mine is a simply and stupid question…can i set on the canvas a button that, if is pressed, can “spawn” a document?
Example, i have this 3d model showing up after being tracked, is possible to insert a button that if is pressed open a pdf on the screen (even an image).
Sorry for the stupid question and thanks in advice.
I use two different ways to get button inputs, I would probably recommend to try 2 first because I find it easier. If you would like me to explain differently or something else, just reply to this reply. After reading what I have wrote, if you want you can watch a youtube video on the UI button that I have attached. If you like this explanation or find it helpful please like it so others can see.
1. You can create a “Sprite (2D and UI)” and put a 2d box colllider onto it then use the function OnMouseDown()
After putting the box collider on, you can create a script to attach to that sprite and use the OnMouseDown() function that will do what you want it to when you click on the box collider
2. You can create a UI button
You can create a panel (GAMBEOBJECT>UI>PANEL). This will also create a canvas which will be the parent of the panel. Then you create a button (GAMEOBJECT>UI>BUTTON). Attach a script to this button with a function that has your code to the document on it. Then click your button and in the inspector scroll to where it says On Click. Then click the plus button. Then drag the GameObject that has the code on it into the box under the box that says runtime only. Then where it says no function, click on that and click on the name of your script then the name of your function. Now on click the button will do that function.
THIS YOUTUBE VIDEO SHOWS HOW TO MAKE UI BUTTONS, CHANGE IT TO APPEAL TO WHAT YOU NEED.
I don’t fully understand your question in your reply, but I will try to answer what I think you meant. If you are using a 2D sprite with a 2D box collider on it, you need to use the OnMouseDown() function and call the function with your code that leads to your document or whatever. If you need more help, just reply again. It should look like this.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class touchInput: MonoBehaviour
{
public void OnMouseDown ()
{
documentCode()
}
public void documentCode()
{
//write code that leads you to document or whatever here
}
}
Also, sorry for the slight spam/delete of the reply but Unity didn’t let me edit my original post and I was trying to reupload it but it wasn’t working, what is up now should work.
You could also use Touch instead and cast a ray which I find helpful for mobile apps if you are still interested.
[Unity - Scripting API: Input.GetTouch