Unity Community


Results 1 to 9 of 9

  1. Posts
    64

    Simple Input Text Field?

    I need a simple input TextField in Unity, for example for writing the user's name.
    Something like the Input Text Fields in Flash would be perfect.
    When the users clicks on them typing is enabled.

  2. Volunteer Moderator
    Posts
    23,709
    GUI.TextField.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  3. Posts
    64
    Quote Originally Posted by Eric5h5 View Post
    GUI.TextField.

    --Eric
    Can you provide example code?
    GUI.TextField(new Rect(32, 32, 180, 32), "xd");
    This gives me an error.

  4. Volunteer Moderator
    Posts
    23,709
    The docs have sample code. You really need to say what the error is; "this give me an error" doesn't help much.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  5. Posts
    64
    The exact code I posted gives me the following error:
    "NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.GUIUtility.GetControlID (FocusType focus, Rect position)
    UnityEngine.GUI.TextField (Rect position, System.String text)
    Main.Start () (at Assets/Main.cs:12)
    "


  6. Posts
    64
    Wow, sorry, I forgot to put it inside OnGUI...


  7. Posts
    64
    Also, any idea how to restrict the input to only numbers?

  8. Volunteer Moderator
    Posts
    23,709
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  9. Posts
    64
    Quote Originally Posted by Eric5h5 View Post
    Thanks so much, it all works ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •