Question by
ritoban · May 05, 2017 at 04:07 PM ·
camerauiinputeventsysteminputfield
Check if EventSystem is in InputField
I have a basic InputField. I also have a basic CameraMovement script:
These are the only relevant lines in the CameraMovement scripts:
Camera.transform.Translate(
Input.GetAxis("Horizontal") * MovementSpeed * KeyboardSensitivity * Time.deltaTime,
0,
Input.GetAxis("Vertical") * MovementSpeed * KeyboardSensitivity * Time.deltaTime,
Space.World);
The problem is when I am typing in the input field, I don't want the Camera to move (when I type the WASD keys). I've already tried adding in a check for EventSystem.current.alreadySelecting
, but that doesn't seem to have changed anything.
Comment
Answer by PizzaPie · May 05, 2017 at 06:05 PM
No clue when alreadySelecting is returning true so a work "around" would be to do something like this:
GameObject inputGameObject;
if (EventSystem.current.currentSelectedGameObject ==inputGameObject)
{
//do something
}
keep in mind the code in the if will be executed every frame you have selected the InputGO a good practice would be to make it execute only once. Cheers