Skip to content

Instantly share code, notes, and snippets.

@ryosebach
Last active June 12, 2018 15:42
Show Gist options
  • Select an option

  • Save ryosebach/dfb8552697e8b1c58aebd6766f9bfe86 to your computer and use it in GitHub Desktop.

Select an option

Save ryosebach/dfb8552697e8b1c58aebd6766f9bfe86 to your computer and use it in GitHub Desktop.
再生時にシーンをセーブする
/*
Copyright (c) 2018 ryosei ogawa
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
[InitializeOnLoad]
public class AutosaveOnRunning : ScriptableObject
{
static AutosaveOnRunning()
{
EditorApplication.playModeStateChanged += (_) => {
if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
{
EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
AssetDatabase.SaveAssets();
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment