I’m working on a project that uses a Bluetooth signal sending data on the amount of force detected by a sensor. We’re using that to move our character. We pushed all of the reading from the sensor to another thread to significantly cut down on a bottleneck in our code.
An issue came up where if other developers didn’t have the sensor attached they wouldn’t be able to test their changes to the project. So, I wrote up a mock object that gets used when no sensor is available. The only thing is I’d prefer to be able to use keypresses to simulate different input speeds, without needing the sensor. The only thing is Input.GetKey
can only be called on the main thread. Since this is only used in the editor, and it wouldn’t make sense to chanage the ReadData()
interface just for debugging is there anyway to just use plain C# to detect keypresses on other threads?
Everything I’ve found on it seems to require Windows Forms, and I don’t think it’s the best idea to add that assembly to the project.