Search Unity

Unity 4.6 Canvas InputField not displaying inputed text

Discussion in 'UGUI & TextMesh Pro' started by steb92, Apr 20, 2015.

  1. steb92

    steb92

    Joined:
    Nov 7, 2014
    Posts:
    29
    Hi all,

    My InputField doesn't update as the user types in to it, so you can't see what you've typed. It records the string when the user presses Enter/Return, but I want it to to display as they type. You'll see below that I've used Debug.Log(); to print out the input field string, which reads 'Stephen' down the button, but it doesn't get shown in the field.

    Any suggestions?
    Capture.PNG
     
  2. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    It would be better for us if we could see the Canvas hierarchy and component parameters in the Inspector.
    Maybe text color is the same color as background?
     
  3. DWilliams

    DWilliams

    Joined:
    Jan 12, 2015
    Posts:
    63
    I suspect that the font size is too big for the size of the input field.
     
  4. steb92

    steb92

    Joined:
    Nov 7, 2014
    Posts:
    29
  5. steb92

    steb92

    Joined:
    Nov 7, 2014
    Posts:
    29
    Anyone??
     
  6. OldManAnimal

    OldManAnimal

    Joined:
    Jul 10, 2014
    Posts:
    45
    There could be any number of things happening. While in play mode, does the Text child gameobject get the typed value assigned to it? Does it somehow get disabled? Either the component or the gameobject? Does it get moved somehow? If you create a new inputfield and not change anything, does that new one work? Does the placeholder text show up? Have you tried adjusting the font size of the Text object like the above suggestion? Have you tried adjusting the colors? Have you tried adjusting the size of the inputfield? The anchors, offsets, etc.?
     
  7. steb92

    steb92

    Joined:
    Nov 7, 2014
    Posts:
    29
    This is my script that I'm using to record the name.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class InputName : MonoBehaviour
    6. {
    7.     Name pname;
    8.     string username = "";
    9.     InputField nametf;
    10.     Text nameDisplay;
    11.  
    12.     void Start()
    13.     {
    14.         GameObject nHolder = GameObject.Find("NameHolder");
    15.         pname = nHolder.GetComponent<Name>();
    16.  
    17.         var input = gameObject.GetComponent<InputField>();
    18.         var se = new InputField.SubmitEvent();
    19.  
    20.         se.AddListener(SubmitName);
    21.         input.onEndEdit = se;
    22.  
    23.     }
    24.  
    25.     private void SubmitName(string arg0)
    26.     {
    27.         username = arg0;
    28.         Debug.Log(username);
    29.         pname.player_name = username;
    30.  
    31.     }
    32.  
    33.     void Update()
    34.     {
    35.  
    36.     }
    37.  
    38. }
     
  8. steb92

    steb92

    Joined:
    Nov 7, 2014
    Posts:
    29
    Bump!
     
  9. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Try reducing the text size or enabling vertical overflow?
     
  10. steb92

    steb92

    Joined:
    Nov 7, 2014
    Posts:
    29
    You legend! Thank you! haha!
     
  11. ContractorNation

    ContractorNation

    Joined:
    Feb 18, 2019
    Posts:
    5
    Also check the placeholder's rect, it doesn't scale when changing the input field's rect.