I hope unity auto save my scene per 30 seconds, so I try following code:
using System;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
[InitializeOnLoad]
public class AutoSave : EditorWindow
{
static AutoSave()
{
Debug.Log($"AutoSave is ii");
EditorApplication.playmodeStateChanged = () => { Save(); };
}
static void Save()
{
var sceneName = "ss1";
EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByName(sceneName));
Debug.Log("Save Scene " + sceneName);
}
private DateTime lastTime = DateTime.Now;
private void Update()
{
if ((DateTime.Now - lastTime).TotalSeconds > 30)
{
lastTime = DateTime.Now;
Save();
}
}
}
but Debug.Log("Save Scene " + sceneName) doesn’t show in unity console