using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FollowMouse : MonoBehaviour {
void Update()
{
if(Input.GetMouseButton(0))
{
Vector3 tmp = Camera.main.WorldToScreenPoint(transform.position);
tmp = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, tmp.z));
transform.position = tmp;
}
}
}
Unity 坐标转换之3D物体跟随鼠标移动
最新推荐文章于 2024-07-17 19:50:36 发布