EditorUtility.ResetToPrefabState 重设到预置状态

static function ResetToPrefabState (obj : Object) : bool

Description描述

Resets the properties of the component or game object to the parent prefab state

重设组件或游戏物体的属性到父预置状态。

All overrides will be cleared. However the transform.position and rotation of a root game object in a prefab instance will never be cleared.

所有覆盖将被清除。然而,预设实例根游戏物体的transform.position 和 rotation,将不会被清除。

// Try to set the selected GameObject to a prefab state
//尝试设置选择的游戏物体到预置状态
class EditorUtilityResetToPrefabState extends ScriptableObject {

	@MenuItem("Examples/Attempt to reset to prefab %r")
	static function Reset() {
		if(EditorUtility.ResetToPrefabState(Selection.activeGameObject))
			Debug.Log("Reseted to prefab state successfully!");
		else
			Debug.LogError("Couldnt reset to a prefab state " + Selection.activeGameObject.name);
	}
	@MenuItem("Examples/Attemp to reset to prefab %r", true)
	static function CheckReset() {
		return Selection.activeGameObject != null;
	}
}
最后修改:2011年7月16日 Saturday 10:53

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。