Hi,
I’m using futile to create a 2d game prototype. I have a textbox where user input is stored, but the backspace key doesn’t work automatically so I had created the following:
public void HandleInput()
{
DisplayInput.text = DisplayInput.text + Input.inputString;
if(Input.GetKey(KeyCode.Backspace))
{
if(DisplayInput.text.Length != 0)
DisplayInput.text = DisplayInput.text.Remove(DisplayInput.text.Length -1);
}
}
This problem is that this script removes mutiple characters (since backspace is held for multiple frames.
So I changed the code to the following:
public void HandleInput()
{
DisplayInput.text = DisplayInput.text + Input.inputString;
if(Input.GetKeyUp(KeyCode.Backspace)) //this is the only line that changed
{
if(DisplayInput.text.Length != 0)
DisplayInput.text = DisplayInput.text.Remove(DisplayInput.text.Length -1);
}
}
This does not remove any characters, when I add a Debug.Log I can see that the function does fire when the backspace key is released, it just doesn’t remove the characters.
Any help would be great.