static void CreateSpec() { GameObject sel = Selection.activeGameObject; UnityEngine.Object ret = PrefabUtility.GetPrefabParent(sel); if (ret != null) { GameObject prefab = (GameObject)ret; //Initialize spec with prefab path. TypeSpec spec = new TypeSpec() { prefabName = AssetDatabase.GetAssetPath(prefab), specName = "Default" }; PropertyModification[] mods = PrefabUtility.GetPropertyModifications(sel); //Add all the changed properties to the type spec. foreach (PropertyModification mod in mods) { //Ignore properties that deal only with the game object or the transform SerializedObject so = new SerializedObject(mod.target); SerializedProperty prop = so.FindProperty(mod.propertyPath); System.Type compType = so.targetObject.GetType(); if (compType != typeof(UnityEngine.Transform) && compType != typeof(UnityEngine.GameObject)) { spec.AddDelta(compType.ToString(), mod.propertyPath, prop.propertyType.ToString(), mod.value.ToString()); } } //Write the type spec out to a file. string path = Application.streamingAssetsPath + "/Specs/" + spec.specName + ".xml"; XmlSerializer xs = new XmlSerializer(spec.GetType()); StreamWriter writer = new StreamWriter(path); xs.Serialize(writer, spec); writer.Close(); //TODO:Update all objects using the same spec/having the same differences from the prefab to match, carry the spec name with them. } }