Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Resolved InputsField

Discussion in 'Scripting' started by Nixel2013, Sep 1, 2023.

  1. Nixel2013

    Nixel2013

    Joined:
    May 9, 2019
    Posts:
    139
    How do I make it so that when an InputField has a numerical value and I delete it, it goes back to 0, but when I modify it, the correct number is displayed and it doesn't end up like this: "20"?

    https://postimg.cc/239DQDN1 (I leave the link, apparently the forum does not allow me to place the image :p)

    if you see, the black line is in a position which does not allow the 2 to be placed correctly, and instead a 20 is left
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    I would say, if the value is 0 when the user clicks on it, just clear the input field. Then, if the user deletes all the numbers, you could just populate it with a 0 again when they deselect it.
     
    Nixel2013 likes this.
  3. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    700
    You can make it so that the whole textfield is selected when you click on it.
     
    Nixel2013 likes this.
  4. Nixel2013

    Nixel2013

    Joined:
    May 9, 2019
    Posts:
    139
    you're right, that hadn't occurred to me, thanks