【发布时间】:2014-03-13 03:40:18
【问题描述】:
在类中使用我在类外声明的变量时遇到问题。如果我尝试这个,Unity 的行为就像变量不存在一样。
#pragma strict
var chunkWidth=49;
class Chunk{
var width:short;
var position:Vector3;
function Chunk(pos:Vector3){
this.width=chunkWidth; //this gives the error: Unknown identifier: 'chunkWidth'.
this.position=pos;
}
}
当我想在类中使用函数时也会发生此错误。
【问题讨论】:
-
你想用这个作为常量吗?或者为什么它被放在一个类之外?
-
我在课堂外使用它,所以我可以在 Unity 中滑动宽度。
标签: function class unity3d unityscript