EDIT: Actually, I just found out this is a completely different issue. It’s not related to preprocessors. They do work. What doesn’t work anymore is getting input from the keyboard: csharp*__ <strong>*if (Input.GetKeyDown("l")) {Debug.Log("Pressed L");}*</strong> __* None of my Input.GetKey or Input.GetKeyDown are getting called. Touch input works still fine using UnityRemote 4.
Hello everyone!
Is this a bug or am I missing something?
I tried using #if UNITY_EDITOR #endif for code that is for testing only.
In C#, this works perfectly, but when doing this in Javascript, it won’t be called.
I just found out this issue is related to Input rather than preprocessors, which I just edited in my original post. Thanks for your reply, though! I didn’t know about #ifdef!
out of curiosity if someone told you “my input doesn’t work” and expected you to know what the problem was based purely on that, what would you tell them?
(from edited original post)
in Update() and press the L button, there won’t be a message in the console.
On the other hand, all the touch events in Update() work when using UnityRemote, though.
Try using the Input.GetKeyDown(KeyCode code) overload. The string overload probably parses it to the KeyCode enum, which defines L but not l (non-capital L) (maybe it’s case sensitive, no idea).
@Zuntatos @martinmr
Thanks for your help! It works now. I already tried using KeyCode yesterday and it failed, too. Today, after changing, it work. This was kind of weird to me (because it wouldn’t work yesterday), so I changed it back to the version without KeyCodes and it works as well.
I don’t really know what this problem was about. Maybe the editor or my machine just needed a restart for whatever reason. You’re right about using KeyCodes, though. The non-KeyCode version sure is more prone to typos.