public Transform root ;

Description

返回层级视图中最顶层的变换。

(永远不返回 null;如果该变换没有父级,则返回自身。)

using UnityEngine;
using System.Collections;

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