So, I’m trying to make a code to grub the player in every scene and revert it to it’s prefab values. Something must be wrong because it doesn’t seem to be working.
I’m using PrefabUtility.RevertPrefabInstance(player); where player is a gameObject.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using System.Collections;
public class zCambiarTodasLasEscenas : ScriptableWizard
{
public Object[] scenes; //An array with al the scenes I want to modify
//creating a wizard menu
[MenuItem("Tools/CambiarTodasLasEscenas")]
static void CreateWizard()
{
ScriptableWizard.DisplayWizard("Edit Scenes", typeof(zCambiarTodasLasEscenas), "Run");
}
void OnWizardCreate()
{
//For each scene
foreach (Object s in scenes)
{
string path = AssetDatabase.GetAssetPath(s); //get the scene's path
EditorSceneManager.OpenScene(path); //open the scene
GameObject player = GameObject.FindGameObjectWithTag("Player");//find the player (is a prefab instance)
PrefabUtility.RevertPrefabInstance(player); /////////Revert the instance to the prefab values.
EditorApplication.SaveScene(path); //Save the scene.
}
}
}