Skip to content

Instantly share code, notes, and snippets.

@shahin-dev
Created March 24, 2015 12:04
Show Gist options
  • Save shahin-dev/2b9894e7a9474ac97770 to your computer and use it in GitHub Desktop.
Save shahin-dev/2b9894e7a9474ac97770 to your computer and use it in GitHub Desktop.
revert to prefab
Well after more unsuccessful searching I read up on the Editor scripting reference and managed to write a script that resets all selected GameObjects to their prefab settings.
@MenuItem ("Tools/Revert to Prefab %r")
static function Revert() {
var selection = Selection.gameObjects;
if (selection.length > 0) {
for (var i : int = 0; i < selection.length; i++) {
EditorUtility.ResetGameObjectToPrefabState(selection[i]);
}
} else {
Debug.Log("Cannot revert to prefab - nothing selected");
}
}
As I said I'm new to scripting the editor and it may not be the best way to do this but it works for me and that's all I need right now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment