我能解释一下为什么 Quaternion.identity 的 Q 是大写的,而 transform.position 是小写的 t 吗?
Can I get an explanation about why Quaternion.identity has a capital Q but transform.position is lower case t?
我能解释一下为什么 Quaternion.identity 的 Q 是大写的,而 transform.position 的 T 是小写的吗?是因为他们使用了不同的指令或程序集吗?
private void Fire()
{
GameObject enemyLaser = Instantiate
(enemyLaserPrefab, transform.position,
Quaternion.identity)
as GameObject;
}
这是 Unity3d 的命名约定。类型 Quaternion
是大写的。但是他们使用 "camel case" 作为属性和字段。因此未大写的 identity
.
完全随意,但在整个Unity3d中是一致的API。
请注意,因为 identity
是静态成员,所以可以通过声明它的类型 (Quaternion
) 访问它。您正在查看的其他成员 transform
和 position
都是当前 class 的成员。 transform
属性 returns 为当前对象的变换对象,position
属性 returns 为变换对象的位置对象。因为它们都是 class 成员,而不是类型名称,所以它们也是驼峰式的。
因为 Quaternion
refers to a type since idendity
is static
while transform
refers to an instance property of type Transform
附加到与脚本相同的 GameObject
。
出于某种原因,Unity 对属性使用驼峰式命名法。通常你实际上会为 public
属性使用 PascalCase,但那些是 "conventions" 并且基本上你可以决定使用其他符号 - 至少它们保持基本一致。
我能解释一下为什么 Quaternion.identity 的 Q 是大写的,而 transform.position 的 T 是小写的吗?是因为他们使用了不同的指令或程序集吗?
private void Fire()
{
GameObject enemyLaser = Instantiate
(enemyLaserPrefab, transform.position,
Quaternion.identity)
as GameObject;
}
这是 Unity3d 的命名约定。类型 Quaternion
是大写的。但是他们使用 "camel case" 作为属性和字段。因此未大写的 identity
.
完全随意,但在整个Unity3d中是一致的API。
请注意,因为 identity
是静态成员,所以可以通过声明它的类型 (Quaternion
) 访问它。您正在查看的其他成员 transform
和 position
都是当前 class 的成员。 transform
属性 returns 为当前对象的变换对象,position
属性 returns 为变换对象的位置对象。因为它们都是 class 成员,而不是类型名称,所以它们也是驼峰式的。
因为 Quaternion
refers to a type since idendity
is static
while transform
refers to an instance property of type Transform
附加到与脚本相同的 GameObject
。
出于某种原因,Unity 对属性使用驼峰式命名法。通常你实际上会为 public
属性使用 PascalCase,但那些是 "conventions" 并且基本上你可以决定使用其他符号 - 至少它们保持基本一致。