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

[solved] How to make a texfield work when using a GUIskin?

Discussion in 'Immediate Mode GUI (IMGUI)' started by Bluestrike, May 29, 2010.

  1. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    How can I make a textfield that works when its in a gui using a GUIskin?
    When using a GUIskin I can delete the text but not enter a new text, when I remove the GUIskin it works just fine.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Can you post the code you are using for this?
     
  3. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    Extracted this from my code, when I assign the gui skin in the inspector i can delete text but typing new text casues the error:

    Code (csharp):
    1.  
    2.  
    3.  
    4. @script ExecuteInEditMode()
    5.  
    6. var gSkin                               : GUISkin ;
    7.  
    8. private var optionsMenu             : boolean = true;
    9.  
    10. private var playerName          : String = "Rollie Wollie";
    11. private var showHints           : boolean = true ;
    12. private var showFPS             : boolean = false ;
    13.  
    14.  
    15.  
    16.  
    17. //-----------------------------------------------------
    18. //
    19. //-----------------------------------------------------
    20. function OnGUI()
    21. {
    22.     if (gSkin)
    23.     {
    24.         GUI.skin = gSkin ;
    25.     }
    26.     else
    27.     {
    28.         Debug.Log("StartMenuGUI: GUI Skin missing!") ;
    29.     }
    30.    
    31.     if (optionsMenu)
    32.     {
    33.         ShowOptionsMenu() ;
    34.     }
    35. }
    36.  
    37.  
    38. //----------------------------------------------------------------
    39. // OPTIONS menu.
    40. //----------------------------------------------------------------
    41. function ShowOptionsMenu()
    42. {
    43.     GUI.BeginGroup (Rect (Screen.width / 2 - 512, Screen.height / 2 - 384 , 1024, 768));
    44.         // show the group area, must be as big as the begingroup setting
    45.         GUI.Box (Rect (0,0,1024, 768), "Group is here");  
    46.    
    47.    
    48.         // ROW 1
    49.         GUI.BeginGroup (Rect (100, 250, 240, 348));
    50.        
    51.             // NAME
    52.             GUI.Label (Rect (0, 0 , 300, 30), "Player name:  " ) ;
    53.             playerName = GUI.TextField (Rect (0 , 30, 200, 25), playerName);
    54.            
    55.             // HINTS
    56.             showHints = GUI.Toggle (Rect (0, 60, 200, 30), showHints, "   Show hint objects");
    57.            
    58.             // FPS
    59.             showFPS = GUI.Toggle (Rect (0, 90, 200, 30), showFPS, "   Show framerate");
    60.            
    61.  
    62.         // no }
    63.         GUI.EndGroup ();
    64.        
    65.         // ROW 2
    66.         GUI.BeginGroup (Rect (390, 250, 240, 348));
    67.             //GUI.Box (Rect (0,0,240,348), "Group is here");
    68.            
    69.         // no }
    70.         GUI.EndGroup ();
    71.  
    72.  
    73.     GUI.EndGroup ();
    74. }
    75.    
    76.  
     
  4. Bluestrike

    Bluestrike

    Joined:
    Sep 26, 2009
    Posts:
    256
    Fixed, creating a guiskin does not set a font for textfields.
    *edit* for some reason the Arial Rounded Bold font also breaks it, is that the default font perhaps?