纳金网

标题: C#写的脚本,作用是鼠标拖动物体,但是出现了错误 [打印本页]

作者: 雅雅    时间: 2013-6-29 15:57
标题: C#写的脚本,作用是鼠标拖动物体,但是出现了错误
代码如下:
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)




欢迎光临 纳金网 (http://course.narkii.com/club/) Powered by Discuz! X2.5