假设下面只涉及类型Transform和类型GameObject
现有Transform的实例t。t代表下列哪一个?
1.三元组(位置、旋转、缩放);
2.t唯一地确定了一个GameObject的实例。
我认为是第二个,因为Transform有实例方法GetComponent()。例如GetComponent在下面的脚本中出现:
public class BulletCreater : MonoBehaviour {
public Transform bullet;
// Use this for initialization
void Start () {
BulletForward bulletForward = bullet.GetComponent<BulletForward> ();
if (bulletForward != null) {
Debug.Log (bulletForward.velocity);
}
}
// Update is called once per frame
void Update () {
}
}
上述脚本涉及了素材(Asset):
@prefab Bullet
使用脚本@ref "BulletForward"
@script BulletForward 控制子弹向前
拥有属性public velocity
@script BulletCreater
另外,Transform的两个实例t1和t2等价的充要条件是什么?
1.两个实例代表的位置、旋转、缩放均等价
2.t1和t2确定了同一个gameObject,其中gameObject是GameObject的实例