Version: 2022.1
public Transform root ;

描述

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

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

using UnityEngine;

public class Example : MonoBehaviour { // Is a collision between two objects with different roots? void OnCollisionEnter(Collision collision) { if (collision.transform.root != transform.root) { print("The colliding objects are not in the same hierarchy"); } } }