I was very pessimistic so i kinda started working on a way to let the user enter their own shortcuts, Undo, Redo, etc…
ex:
I had to go through the Unity Editor Menus to manually build a List of the Menus with shortcuts… which i’ll check against when the user tries to set a shortcut while in the TextField (light green).
ex:
So far this seems the less aggressive approach, having the user specify a NEW Shortcut for Undo/Redo for my EditorWindow, since i rather not get into .net Reflection and try and see if i can hack my way into Overloading the default Unity Editor Shortcuts.
ohh, i have to check if its the MAC, instead of Ctrl i think it uses Cmnd.
No that can’t work, you need to capture that event en-route, not at some haphazard moment in time.
Here, try this.
// EventConsumeTest.cs
using UnityEngine;
public class EventConsumeTest : MonoBehaviour {
[SerializeField] bool suppressKeyboard;
}
// EventConsumeTestEditor.cs
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(EventConsumeTest)]
public class EventConsumeTestEditor : Editor {
void OnEnable() {
SceneView.duringSceneGui += sceneCallback;
}
void OnDisable() {
SceneView.duringSceneGui -= sceneCallback;
}
void OnDestroy() => OnDisable();
void sceneCallback(SceneView view) {
if(serializedObject.FindProperty("suppressKeyboard").boolValue) {
var e = Event.current;
if(e.isKey) e.Use();
}
}
}
This will work as long as your mouse pointer is in the scene. I don’t have time right now to look for the holistic approach, but it should work and serve as a proof of concept.
Edit:
though your approach might have worked, if only you called Use.
Btw I used this particular way of doing this because I could confirm it in my editor. The only caveat is that the callback is not called if mouse isn’t over the scene.
Thanks, I tried to make this work but I gave up. For unknown reasons, I never receive any callback from “SceneView.duringSceneGui” even though “OnGUI” is called every frame for this game object.
I’m not sure about that. Maybe. My impression is that nothing has changed fundamentally. The new input system is unrelated, and the new UI is basically a redesign of how the UI system is used on top of old stuff. But I should definitely investigate more when I get some time.