Javascript脚本不能在Unity中工作

Javascript脚本不能在Unity中工作,javascript,c#,unity3d,Javascript,C#,Unity3d,我已经用javascript为unity 5编写了一个脚本,通过这个脚本,您应该能够从场景中拾取项目作为第一个perosn角色,并将其位置更改为其他任何位置。但问题是,它只是不起作用。。代码如下: var target = Transform; function Update() { } function OnMouseDown() { this.transform.position = target.position; this.transform.parent = Gam

我已经用javascript为unity 5编写了一个脚本,通过这个脚本,您应该能够从场景中拾取项目作为第一个perosn角色,并将其位置更改为其他任何位置。但问题是,它只是不起作用。。代码如下:

var target = Transform;

function Update() { }

function OnMouseDown() {
    this.transform.position = target.position;
    this.transform.parent = GameObject.Find("FPSController").transform;
    this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}
function OnMouseUp() {
    this.transform.parent = GameObject.Find("FPSController").transform;
    this.transform.parent = null;
}
我将此代码拖动到我的对象(如圆柱体)上,将弹出一个新组件,该组件具有
target
字段选项,并默认设置为空。但是正如您所看到的,组件已经存在,但是选项目标字段没有显示。因此,我无法将我的
PickUpTarget
(它是空的,位于FPSController下)拖放到圆柱体的目标字段!那怎么了?如果我的代码正常,为什么目标字段不显示

还提到我在VisualStudio中收到了一个 打开我的脚本文件:

07:38:18.2125:未找到引用的文件“~/Scripts/\u references.js”


使用
var目标:转换
要获取inspector中显示的变量,它应该有一个冒号,而不是等号