How to change get keydown into Multiple touch in gameObject
I have a Rythm game project and I will build the project on mobile, I use GetButtonDown for my pushbutton I have searched for tutorials and methods several times but am still confused about how to make my button a touch button / multiple touch buttons I tried to use it like the one on YouTube but when I touched the other buttons one touched and when I touched on all parts of the Android screen my buttons were touched too this my code
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Activator : MonoBehaviour { Renderer r; bool active=false; GameObject note,gm; Color lama; public string key; void Awake() { r=GetComponent<Renderer>(); } void Start() { gm=GameObject.Find("GameManager"); lama=r.material.color; } void Update() { if(Input.GetButtonDown(key)) StartCoroutine(tekan()); if(Input.GetButtonDown(key)&&active){ Destroy(note); gm.GetComponent<GameManager>().AddStreak(); AddScore(); active=false; }else if(Input.GetButtonDown(key)&&!active){ gm.GetComponent<GameManager>().ResetStreak(); } } void OnTriggerEnter(Collider col) { if (col.gameObject.tag=="WinNote"){ gm.GetComponent<GameManager>().Win(); } if (col.gameObject.tag=="Note"){ note=col.gameObject; active=true; } } void OnTriggerExit(Collider col) { active=false; gm.GetComponent<GameManager>().ResetStreak(); } void AddScore(){ PlayerPrefs.SetInt("Score",PlayerPrefs.GetInt("Score")+gm.GetComponent<GameManager>().GetScore()); } IEnumerator tekan(){ r.material.color=new Color(0,0,0); yield return new WaitForSeconds(0.1f); r.material.color=lama; } }
and this my button
Sorry im newbie in forum and i use google translate