用户工具

站点工具


侧边栏

script:unityengine:classes:transform:transform.haschanged

Transform.hasChanged 是否被改变

JavaScript ⇒ var hasChanged: bool;
C# ⇒ bool hasChanged;

Description 描述

Has the transform changed since the last time the flag was set to 'false'?

此变换自从上次标识是否被设置为false了?

A change to the transform can be anything that can cause its matrix to be recalculated: any adjustment to its position, rotation or scale. Note that operations which can change the transform will not actually check if the old and new value are different before setting this flag. So setting, for instance, transform.position will always set hasChanged on the transform, regardless of there being any actual change.

对变换的任何改变会导致矩阵的重新计算:任意调节它的位置、旋转或缩放。请注意此操作,是否在设置此标识之前新旧的值不同,也将不会实际检查。因此,对于实例化,transform.position将总是设置此变换的hasChanged,无论是否有实际的变化。

JavaScript:

	function OnUpdate () {
		if (transform.hasChanged)
		{
			print("The transform has changed!");
			transform.hasChanged = false;
		}
	}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    void OnUpdate() {
        if (transform.hasChanged) {
            print("The transform has changed!");
            transform.hasChanged = false;
        }
    }
}

Transform

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