- 最后登录
- 2017-6-30
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 10267
- 纳金币
- 6520
- 精华
- 14
|
代码如下:
using System.Collections; public class clickmove : MonoBehaviour { // Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
IEnumerator OnMouseDown()
{
Vector3 ScreenSpace = Camera.main.WorldToScreenPoint(transform.position);
Vector3 offset = transform.position-Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x,Input.mousePosition.y,ScreenSpace.z));
Debug.Log("down");
if(Input.GetMouseButton(0))
{
Vector3 curScreenSpace = Vector3(Input.mousePosition.x,Input.mousePosition.y,ScreenSpace.z);
Vector3 CurPosition = Camera.main.ScreenToWorldPoint(curScreenSpace)+offset;
transform.position = CurPosition;
//yield return new WaitForFixedUpdate();
}
}
}
错误提示:
Assets/script/clickmove.cs(20,65): error CS1502: The best overloaded method match for `UnityEngine.Camera.ScreenToWorldPoint(UnityEngine.Vector3)' has some invalid arguments
(Filename: Assets/script/clickmove.cs Line: 20) Assets/script/clickmove.cs(20,65): error CS1503: Argument `#1' cannot convert `object' expression to type `UnityEngine.Vector3'
(Filename: Assets/script/clickmove.cs Line: 20) Assets/script/clickmove.cs(28,50): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
(Filename: Assets/script/clickmove.cs Line: 28) Refresh, detecting if any assets need to be imported or removed ... 0.001411 seconds (Nothing changed) |
|