Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUILayout.TextField not working i cant input a string

Discussion in 'Scripting' started by Mr.Smart, Aug 19, 2011.

  1. Mr.Smart

    Mr.Smart

    Joined:
    Aug 5, 2011
    Posts:
    54
    guys first time i have problem and don`t have solution for it

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class login : MonoBehaviour {
    6.     public string LoginButtonText = "Login";
    7.     public string uname;
    8.     public string psswr;
    9.     public GUISkin ButtonSkin;
    10.     // Use this for initialization
    11.     void Start () {
    12.    
    13.     }
    14.    
    15.     // Update is called once per frame
    16.     void Update () {
    17.        
    18.     }
    19.     void OnGUI(){
    20.         GUI.skin = ButtonSkin;
    21.         GUI.BeginGroup(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 125, 300, 250));
    22.         //GUI.Box(new Rect(0, 0, 300, 250), "This box is now centered! - here you would put your main menu");
    23.         GUILayout.Label("Username","label");    
    24.         GUILayout.TextField(uname,15,"textfield");
    25.         GUILayout.Label("Passowrd","label");
    26.         GUILayout.TextField(psswr,15,"textfield");
    27.         if(GUILayout.Button(LoginButtonText,"button")){
    28.             Debug.Log("Clicked"+" username:"+uname+" password:"+psswr);
    29.         }
    30.         GUI.EndGroup();
    31.     }
    32. }
    33.  
    34.  
    when i run project i cant input string into textfields , there is no error`s that i can debug it.
     
  2. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    Code (csharp):
    1. uname = GUILayout.TextField(uname,15,"textfield");
     
  3. Mr.Smart

    Mr.Smart

    Joined:
    Aug 5, 2011
    Posts:
    54
    will try now
     
  4. Mr.Smart

    Mr.Smart

    Joined:
    Aug 5, 2011
    Posts:
    54
    Worked Perfectly Thenk`s mate