我能否解释为什么Quaternion.identity具有大写字母Q,而transform.position是小写的t?

问题描述 投票:1回答:2

我是否可以解释为什么Quaternion.identity具有大写字母Q,而transform.position是小写T?是因为他们使用了不同的指令还是程序集?

private void Fire()

 {

    GameObject enemyLaser = Instantiate
    (enemyLaserPrefab, transform.position,
    Quaternion.identity)
    as GameObject;
 }
c# visual-studio unity3d terminology
2个回答
1
投票

这是Unity3d的命名约定。类型Quaternion为大写。但是他们将“驼峰式保护套”用于属性和字段。因此,没有大写的identity

这是完全任意的,但在整个Unity3d API中都是一致的。

请注意,因为identity是静态成员,所以可以通过声明它的类型(Quaternion)访问它。您正在查看的其他成员transformposition都是当前类的成员。 transform属性返回当前对象的变换对象,position属性返回该变换对象的位置对象。因为它们都是类成员,而不是类型名,所以它们也是驼峰式的。


0
投票

因为Quaternion引用type,因为Quaternionidendity,而idendity引用类型staticinstance属性,该属性附加到与脚本相同的transform

出于某种原因,Unity对属性使用camelCase表示法。通常,您实际上将PascalCase用于transform属性,但这些是“约定”,基本上,您可以决定使用其他表示法-至少它们使它保持一致。

© www.soinside.com 2019 - 2024. All rights reserved.