Transform.root 根

var root : Transform

Description描述

Returns the topmost transform in the hierarchy.

返回层次最高的变换。

(This never returns null, if this Transform doesn't have a parent it returns itself.)

这从来不返回null,如果这个变换没有父级,将返回自身。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnCollisionEnter(Collision collision) {
		if (collision.transform.root != transform.root)
			print("The colliding objects are not in the same hierarchy");

	}
}
// Is a collision between two objects in different hierarchies?
//碰撞的两个物体在不同的层次?
function OnCollisionEnter(collision : Collision) {
	if ( collision.transform.root != transform.root ) {
		print("The colliding objects are not in the same hierarchy");
	}
}
Page last updated: 2010-12-19