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.

Revisions

  1. Dmitriy Sidorov created this gist Mar 24, 2015.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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.