using System.Collections; using System.Collections.Generic; using UnityEngine; public class TouchEffect : MonoBehaviour { public Camera m_camera; public GameObject m_effectObject; Vector3 screenPoint; // Start is called before the first frame update void Start() { m_camera = Camera.main; if (m_effectObject) { screenPoint = m_camera.WorldToScreenPoint(m_effectObject.transform.position); } } // Update is called once per frame void Update() { if (Input.GetMouseButton(0)) { var pos = m_camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); m_effectObject.transform.position = pos; } } }