- Home /
Show Panel when 3D model is touched in Vuforia for Android
![I][1] Hi! I am trying to develop an AR app in vuforia and my scripting is not very good as I am a beginner. I want when the user touches the 3D model to show/ pop up a menu panel. I have attouched to my 3D model a collider and a rigidbody which is on trigger and I have attahed this script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PanelOpener : MonoBehaviour {
public GameObject Panel;
public void OpenPanel()
{}
void Update()
{
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit Hit;
if (Physics.Raycast(ray, out Hit) && Hit.collider.gameObject == gameObject)
{
if(Panel != null)
{
Panel.SetActive(true);
}
}
}
}
}
I don't know what I am doing wrong! Please help if anyone knows!
this code seems fine. Aren't you getting the desired result? anyways, you can use mouse methods ins$$anonymous$$d of touch methods (mouse methods can work on both editor and touch devices).
Your answer
Follow this Question
Related Questions
How to display new panel replacing the first one 1 Answer
Problem importing 3D model 0 Answers
How can I instantiate an explosion using Raycasting? 0 Answers
How to draw in specific panel? 0 Answers
Cloud recognition in Vuforia 0 Answers