- Home /
Textfield Not Bound To Rect
I have some code that I am moving from Unity 3.5 to Unity 4. In the original code I have a simple textfield that worked the way I wanted. The text would basically hide when it was at the edges of the rectangle passed in. However, in Unity 4 I see that when I type enough letters to start filling the rect the text just stays on screen and goes outside the bounds I want it to have. Is this an "official" change in Unity 4 or is there something I am missing? Thanks.
function OnGUI(){
if(showTextArea){
if (Event.current.Equals (Event.KeyboardEvent ("return"))){
this.enterBtn();
}
var myFont :GUIStyle = new GUIStyle();
myFont.font = largefont;
myFont.fontSize = 20;
myFont.normal.textColor = Color.white;
GUI.skin.settings.selectionColor = Color.gray;
GUI.SetNextControlName("labelString");
labelString = GUI.TextField(Rect(20,Screen.height - 36, 100, 30),labelString,myFont);
GUI.FocusControl("labelString");
}
}
Answer by justin_iSO · Feb 21, 2013 at 09:48 PM
Figured it out: There is a field called TextClipping that was for some reason defaulted to clip in the first one but not in my current one. So I just explicitly set myfont.clipping to TextClipping.Clip and it worked as I hoped.
Your answer
![](https://koobas.hobune.stream/wayback/20220613093126im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
TextField Query 1 Answer
Gui.textfield empty deletes. 0 Answers
Event.current problem 1 Answer
how to check GUI.TextField Entry 2 Answers
How expensive is Rect.Contains(Event.current.mousePosition)? 1 Answer