using UnityEngine; public class TouchViewer : MonoSingleton { [SerializeField] private GameObject[] touchEffectPool; public Camera UICamera { get; set; } private void Awake() { if (!IsNull() && Instance != this) { Destroy(this); return; } DontDestroyOnLoad(this); } void FixedUpdate() { if (UICamera is null) return; #if UNITY_EDITOR || UNITY_STANDALONE_WIN if(Input.GetMouseButtonDown(0)) #else if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) #endif { Vector3 canvasPosition = UICamera.ScreenToWorldPoint(Input.mousePosition); canvasPosition.z = 0; PlayTouchEffect(canvasPosition); } } private void PlayTouchEffect(Vector3 startPos) { for (int i = 0; i < touchEffectPool.Length; i++) { if (!touchEffectPool[i].activeSelf) { touchEffectPool[i].transform.position = startPos; touchEffectPool[i].SetActive(true); return; } } } }