Files
beyond/Assets/Scripts/UI/TouchEffect.cs
2024-11-20 15:21:28 +01:00

31 lines
789 B
C#

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;
}
}
}