This version of Unity is unsupported.
Method group is Obsolete

PrefabUtility.ResetToPrefabState

Obsolete Use RevertObjectOverride.

Declaration

public static bool ResetToPrefabState(Object obj);

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.

using UnityEngine;
using UnityEditor;

class Example : EditorWindow { // Try to set the selected GameObject to a Prefab state

[MenuItem("Examples/Attempt to reset to Prefab %r")] static void Reset() { if (PrefabUtility.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 bool CheckReset() { return Selection.activeGameObject != null; } }