- Home /
AR Object Button ALMOST FINISHED!!! UNITY/VUFORIA
Hi, my name is David
I'm preparing a gift for a friend of mine that is an artist. I want to make an animated AR version of this painting.
I already made the 3d version and It works in Ar -also with animation-. But I want to animate it from plate to 3D with a Button to click (in this case the triangle in the chest).
I tried to use the following script of @jacksonbarnes but i'm not too good (Just start with unity/vuforia) and I miss a step. Please someone can Help Me?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class WebsiteButton : MonoBehaviour {
public GameObject definedButton;
public UnityEvent OnClick = new UnityEvent();
// Use this for initialization
void Start () {
definedButton = this.gameObject;
}
// Update is called once per frame
void Update () {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit Hit;
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(ray, out Hit) && Hit.collider.gameObject == gameObject)
{
Debug.Log("Button Clicked");
OnClick.Invoke();
}
}
}
}
Thanks in advice,
best regards
D.D.
Answer by Mentaner · Dec 28, 2018 at 11:36 PM
What is it you want to do exacly? Do you just try to activate something when the triangle is pressed ? If that is the case: Have you tried the OnClick method. That should work since touches get registret as clicks.
I want to make a 3D OBJECT (the triangle in the middle of the chest) as button. When it is pressed It has to activate the animation of all the paint (See second picture in my question). It's difficult to find out the right code because I want the animation of the painting but also of the button. I don't want a static-flat button.
THEN: 1 Press the 3D button 2 the button move back (as a button should do) 3 all the paint comes up after this command. (It start the real animation)
P.S. I've already seen a lot of tutorial and forum discussion. The only code close to what I want It's the one i pasted in my question. Other tutorials are too old (and I don't know how to update for the new unity/vuforia versions)
Hope It's clear this time.
Answer by unity_SPXc9aQ2L1Fs8A · Jan 03, 2019 at 01:20 PM
@aldonaletto Please can you check this question?
Your answer
Follow this Question
Related Questions
how to hide this if button click 1 Answer
Using a wireless camera with iPhone/Android 0 Answers
Error with URL video for AR 0 Answers