Expose input devices to editor

Just experimenting with some different input types and wondered how to go about receiving events from input devices in edit mode. I can run scripts and get mouse events and certain key presses but so far no luck with things like joysticks, gamepads and multi-touch trackpads.

Is it at all possible to expose the Input class in edit mode so I can test different input devices without playing?

And if not how would I go about handling it myself. Would I need to write some kind of custom plugin to access hardware?

for some reason I posted an answer instead of a comment, here’s what I meant to say…

You can actually have scripts execute without needing a change to prompt them using delegates.

using UnityEngine;
    using UnityEditor;
    
    [ExecuteInEditMode]
    public class DetectInputEvents : MonoBehaviour {
    
        void OnEnable()
        {    
            Debug.Log("running in edit mode enabled");
            EditorApplication.update += EditorUpdate;
        }
        void EditorUpdate ()
        {   
         //this is what gets executed in edit mode
        }
        void OnDisable()
        {
            Debug.Log("running in edit mode disabled");
            EditorApplication.update -= EditorUpdate;
        }
    }

The above should also work on a ScriptableObject when you don’t want to attach it to a game object. There’s a slightly different method for classes that don’t derive from something with OnEnable().

I’ve been trying to somehow prompt unity to initialize the Input class but I don’t know enough about how it works for anything but a shot in the dark.

I’ve been looking into this myself, and it seems like this is a no-go.

The problem is that outside play mode, the Input class seems to be inactive. This means that you’re stuck with using the UnityEditor.Event system, which doesn’t seem to have any access to anything else than keyboard and mouse input.

Also, when you’re in edit mode, scripts only have their Update() called when something changes in the scene - you move a thing or change a variable or whatever. Which means that even if you could listen for buttons outside of play mode, the scripts that should be listening for them probably won’t be called.

Do post if you find something; I really want to be able to launch the game in the editor with a controller button. Such a hassle to press play with the mouse, and then pick up the controller.