using System.Collections; using System.Collections.Generic; using UnityEngine; public class interfaceScript : MonoBehaviour { string Btn; RaycastHit hit; public GameObject cube; private Renderer cubeRenderer; // Start is called before the first frame update void Start() { cubeRenderer = cube.GetComponent(); } // 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) } } } } }