Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Created November 25, 2019 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiarheiPilat/d2b64eb633d5a0399b3c2ea6e59c21f9 to your computer and use it in GitHub Desktop.
Save SiarheiPilat/d2b64eb633d5a0399b3c2ea6e59c21f9 to your computer and use it in GitHub Desktop.
This tiny class will Autosave your project whenever you play your scene!
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
// Credit goes to Comp-3 Interactive, thanks for sharing the script!
// This tiny class will Autosave your project whenever you play your scene!
[InitializeOnLoad]
public class Autosave
{
static Autosave()
{
EditorApplication.playModeStateChanged += SaveOnPlay;
}
private static void SaveOnPlay(PlayModeStateChange state)
{
if(state == PlayModeStateChange.ExitingEditMode)
{
Debug.Log("Auto-saving...");
EditorSceneManager.SaveOpenScenes();
AssetDatabase.SaveAssets();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment