AR_Celement/Assets/Scripts/interfaceScript.cs
2023-01-10 14:58:52 +01:00

35 lines
969 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class interfaceScript : MonoBehaviour
{
string btnName;
RaycastHit hit;
public GameObject cube;
private Renderer cubeRenderer;
// Start is called before the first frame update
void Start()
{
cubeRenderer = cube.GetComponent<Renderer>();
}
// Update is called once per frame
void Update()
{
if(Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Began ){
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if(Physics.Raycast(ray, out hit)){
btnName = hit.transform.name;
switch (btnName){
case "Cube":
cubeRenderer.material.SetColor("_Color", Color.red);
break;
default:
break;
}
}
}
}
}