Hi! I'm a relatively intermediate developer and I'm having a problem that I'm hoping someone here will have an answer for.
I've been porting a lot of code from a PC pet project to Android over my 2 week break which I get once a year!
I have about 9 hours left of my break and, while using Unity Remote to playtest, with everything working fine, I realize a couple hours ago that, even though earlier today it worked, I am no longer getting "Input" events in my script called.
So I add this to the beginning of the update function that was troubling me, ensuring no other variables were affecting it.
if (Input.GetKeyDown(KeyCode.L))
{
print("Pressed L");
}
I debugged to make sure that update loop was finishing, and it was.
I took out all returns / breaks, and still nothing.
Input from the Unity Remote still is working in that same update loop.
I made a new script, totally new, on an empty gameobject:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputTester : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.anyKey)
print("Hitting some key or another: " + Input.inputString);
}
}
And here is where it gets interesting. Or confusing.
That message only prints for the mouse input.
***However, if I am holding the mouse input down, it will print for other keys!
And while the problematic update is going, even when this script prints that it sees my "L", the first script still doesn't see it.***
What could the problem be? I feel like I didn't change anything about those scripts that would make it ignore input. I don't have any classes or behaviours or methods overriding anything similar to "Input". What could be causing this bizarre behaviour? I've restarted Unity, my computer, my Unity Remote phone, tried minimizing and maximizing every which way at the advice of the internet, but still nothing.
Thanks again for any help
Edit:
I also just tried deleting everything in my scene except that debug log script. Still, same behaviour.
Edit 2:
I made an empty project with "InputTester" and it is working as intended. So, while I wait for a scene to export only to probably produce the same issue, how could I possibly find out what the problem is? What could be taking priority over frikkin' input?
Edit 3: In the new project, I imported my scene, with platform as Windows. Same exact scene as the first project. I run it, and I get input just fine. So I switch my platform to Android and the problem begins again! So I think, huzzah, I have found the issue. But, then I switched back to targeting Windows, and the problem persisted. So, a bug perhaps?
FINAL EDIT / SOLUTION:
I guess this is one of those things I'd probably know if I spent more time looking through documentation. I like to learn the hard way I guess.
To target Android in the editor, and use Unity Remote, and have these scripts see your keyboard input, set "Joystick Source" from "Remote" to "Local" under "Edit > Project Settings> Editor / Unity Remote"
So, the obvious "Duh" here is that, since during runtime on Android you typically won't have access to the keyboard in the same capacity, so my case is a bit special in that, I am - possibly in poor practice - relying on a keyboard press to trigger functions for debugging purposes - namely serializing some transform information to be loaded during runtime through script.
↧