用户工具

站点工具


侧边栏

script:unityengine:classes:transform:transform.root

Transform.root 根对象

JavaScript ⇒ var root: Transform;
C# ⇒ Transform root;

Description 描述

Returns the topmost transform in the hierarchy.

返回最高层级的变换。

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

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

JavaScript:

	// 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");
		}
	}

C#:

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");
 
    }
}

Transform

script/unityengine/classes/transform/transform.root.txt · 最后更改: 2016/08/02 05:37 (外部编辑)