Hi! I have same problem with writing apply prefab script. I found that I have to use "SetPropertyModifications" from "PrefabUtility" but when i use "PrefabUtility" i have "Unknown identifier", so i try "EditorUtility" becouse it worksfine with "CreateEmptyPrefab" and "ReplacePrefab", but now i have "Method not found". Did any one can help me with this problem.
This this code: Code (csharp): using UnityEngine; using UnityEditor; public class ReplacePrefab : EditorWindow { GameObject prefab; GameObject go; [MenuItem ("Prefabs/ReplacePrefab")] static void OpenWindow (){ EditorWindow.GetWindow (typeof (ReplacePrefab)); } void OnGUI (){ go = EditorGUILayout.ObjectField ("GameObject", go, typeof (GameObject), true) as GameObject; prefab = EditorGUILayout.ObjectField ("Target Prefab", prefab, typeof (GameObject), false) as GameObject; if (GUI.changed prefab != null){ PrefabType prefabType = PrefabUtility.GetPrefabType(prefab); if (prefabType != PrefabType.Prefab) prefab = null; } if (go != null prefab != null){ if (GUILayout.Button ("Replace")){ PrefabUtility.ReplacePrefab(go, prefab, ReplacePrefabOptions.ConnectToPrefab | ReplacePrefabOptions.ReplaceNameBased ); GUIUtility.ExitGUI(); } } } }