Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Hannibal_Leo · May 08, 2017 at 05:40 PM · savecustom editor

[SOLVED] How to track CRTL + S in editor window?

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Hannibal_Leo · May 15, 2017 at 02:32 PM

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);
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

67 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Objects instantiated in custom editor not saving. 0 Answers

How can I instantiate a list in a gameobject in a scene in edit mode, and have that list persists when I press play and then after I exit play? 0 Answers

Saving player position 1 Answer

Saving Project causes Unity Game Engine to lose focus. Why? 0 Answers

ScriptableObject asset not saved to disk 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges