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;
	}
}
Page last updated: 2011-7-16