Okay, I searched for an hour to solve this, time to ask questions:
I already tried to use: [MenuItem(“InGameLists/SaveEditor %s”)] - “%” is “CRTL”, “s” is “S-Key” but this didn’t work, then I searched everywhere and everybody just want to track the save function unity has, but I don’t change things in the scene, I have my custom serialisation to use OOP features in a database and I want to save it with CRTL + S, but I cannot track those buttons somehow.
Any ideas?
Got it - after days of work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class SREditorAutoSave {
bool crtlKeyDown = false;
public void AutoSave(Event e)
{
if (e.keyCode == KeyCode.LeftControl && e.type == EventType.KeyDown)
{
crtlKeyDown = true;
}
if (e.keyCode == KeyCode.LeftControl && e.type == EventType.KeyUp)
{
crtlKeyDown = false;
}
if (e.keyCode == KeyCode.S && crtlKeyDown)
{
Debug.Log("saved from crtl s");
SRSaveEditorDatabase.Save();
}
AutoSaveTimer();
}
double timer = 0;
void AutoSaveTimer()
{
if(EditorApplication.timeSinceStartup > timer)
{
timer = EditorApplication.timeSinceStartup + (double)(2 * 60); // 2 Minutes
SRSaveEditorDatabase.Save();
}
}
}
on every editor in my system I just use:
SREditorAutoSave saveEditorHelper = new SREditorAutoSave();
void OnGUI(){
//check event
Event e = Event.current;
saveEditorHelper.AutoSave(e);
}