Created
May 16, 2016 16:14
-
-
Save strich/ff3308301d6f1de01f9589a7f54b2768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using System; | |
using UnityEditor.SceneManagement; | |
using UnityEngine; | |
[InitializeOnLoad] | |
public class ForceEditorWriteToDisk { | |
private static bool _flushAssets = true; | |
private static bool _flushScenes = false; | |
static ForceEditorWriteToDisk() { | |
Undo.willFlushUndoRecord += FlushToDisk; | |
Undo.undoRedoPerformed += FlushToDisk; | |
//Undo.postprocessModifications += blah; | |
} | |
//private static UndoPropertyModification[] blah(UndoPropertyModification[] mods) { | |
// Debug.Log("UndoPropertyModification"); | |
// return mods; | |
//} | |
private static void FlushToDisk() { | |
if (_flushAssets) FlushAssetsToDisk(); | |
if (_flushScenes) FlushScenesToDisk(); | |
} | |
private static void FlushAssetsToDisk() { | |
EditorApplication.SaveAssets(); | |
} | |
private static void FlushScenesToDisk() { | |
EditorSceneManager.SaveOpenScenes(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment