很基本的操作,不过一开始做的时候用OnMouseDown做的,不适用与移动平台,在网上查的内容也都是用鼠标控制拖曳的,自己写了个通过Input实现的移动终端和PC端都可以使用的拖曳脚本,代码如下:
using UnityEngine;
using System.Collections;
public class Drag3dController : MonoBehaviour
{
public Camera ARCamera;
public GameObject m_targetObj;
private float f_maxDis ;
private bool dragAble = true;
public void SetDragAble()
{
dragAble = true;
isFirstSet = true;
f_maxDis = Vector3.Distance(transform.position, m_targetObj.transform.position)/3;
}
private void OnEnable()
{
dragAble = false;
isFirstSet = true;
transform.localPosition = Vector3.zero;
}
bool isFirstSet = true;
Vector3 offset;
private void Update()
{
<