- Home /
Question by
DanielJF · Jan 29, 2013 at 04:26 PM ·
onguitextfieldparsegui.window
Gui.textfield empty deletes.
Hello everyone i have a problem with my GUI.
This is the problem : I can add now numbers in my GUI Window but the problem is if there is nothing inside of the string it just kills the whole window.
here is some code hope you can help.
string healthString = "1234567890";
string armorString = "1234567890";
void OnGUI ()
{
bi.armor = float.Parse(armorString);
bi.health = float.Parse(healthString);
GUI.Window(0,new Rect(10,10,200,300),DoMyWindow,"Stats");
GUI.Label(new Rect(20,30,200,20), "EnemyHealth: ");
healthString = GUI.TextField(new Rect(105,30,40,20),healthString,25);
GUI.Label(new Rect(20,50,200,20), "EnemyArmor: ");
armorString = GUI.TextField(new Rect(105,50,40,20),armorString,25);
GUI.Label(new Rect(20,70,200,20), "EnemyMagicResist: "+Mathf.Round(bi.magicResist));
GUI.Label(new Rect(20,90,200,20), "YourAD: "+Mathf.Round(bi.enemyAD));
GUI.Label(new Rect(20,110,200,20), "YourDamage: "+Mathf.Round(bi.realDamageAR));
}
The vars bi.health etc is an reffrence to another script
thx for your time hope you can help me
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613091808im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Changing variables in real time. 2 Answers
Textfield Not Bound To Rect 1 Answer
GUI.window Not Displaying 2 Answers
GUI.Window only shows for one frame under all circumstances 2 Answers