String Space In keyboard

Hi,I 'm making a keyboard in UI for Unity but I’m not sure how to simulate the space button via button.This is what I found :

public void ClickBackspace()
    {
        string tempGetString = myText.text;
        if(tempGetString.Length > 0)
        {
            string tempString = tempGetString.Substring(0, tempGetString.Length -1);
            myText.text = tempString;
        }
    }

In this way I simulate the delete button so according to my logic with this it becomes the space but it doesn’t work

public void Clickspace()
    {
        string tempGetString = myText.text;
        if(tempGetString.Length > 0)
        {
            string tempString = tempGetString.Length +1;
           myText.text = tempString;
        }
    }

Thanks for the help :slight_smile:

why not just do
string tempString = tempGetString + " ";

1 Like

Ho thanks for your reply I tried you solution but insted of a space it simulate a button null no input

public void Clickspace()
{
    myText.text += " ";
}

doesn’t need any of the checking you’ve copy/pasted across from the deletion/backspace function.

1 Like

Thanks both of you .LeftyRighty very good suggestions thanks :slight_smile: