I have using Model Target with much success, however, i would like to interact with the model produced after it recognizes the target.
Objective: the model should be invisible on start, but upon touching once, the model appears along with an image.
this works perfectly fine when i did it with an empty scene with a cube and random image. But somehow didnt work with Vuforia.
Can someone shed some light?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class TouchPlay : MonoBehaviour
{
public Image Image;
void Start()
{
var rend = gameObject.GetComponentInChildren<Renderer>(false);
rend.enabled = !rend.enabled;
Image.enabled = false;
}
// Update is called once per frame
void Update()
{
if(Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay(Input.touches[0].position);
RaycastHit hit;if(Physics.Raycast(ray, out hit))
{
if(hit.collider != null)
{
var rend = gameObject.GetComponentInChildren<Renderer>(true);
rend.enabled = Image.enabled = !rend.enabled;
}
}
}}
}