private int HandleAltitudeGUI(AltitudeSetGUI altitude, int y) { GUIStyle gs = new GUIStyle(GUI.skin.label); gs.alignment = TextAnchor.MiddleRight; GUIStyle texFieldGS = new GUIStyle(GUI.skin.textField); Color errorColor = new Color(1, 0, 0); Color normalColor = texFieldGS.normal.textColor; float dummyFloat; GUI.Label(new Rect(10, y, 65, 25), "Altitude: ", gs); if (float.TryParse(altitude.AltitudeS, out dummyFloat)) { texFieldGS.normal.textColor = normalColor; texFieldGS.hover.textColor = normalColor; texFieldGS.active.textColor = normalColor; texFieldGS.focused.textColor = normalColor; } else { texFieldGS.normal.textColor = errorColor; texFieldGS.hover.textColor = errorColor; texFieldGS.active.textColor = errorColor; texFieldGS.focused.textColor = errorColor; } String sAltitude = GUI.TextField(new Rect(80, y, 50, 25), altitude.AltitudeS, texFieldGS); float fAltitude = GUI.HorizontalSlider(new Rect(135, y + 5, 115, 25), altitude.AltitudeF, 0, 22000); altitude.Update(fAltitude, sAltitude); return(y + 30); }
private int HandleAltitudeGUI(AltitudeSetGUI altitude, int y) { GUIStyle gs = new GUIStyle(GUI.skin.label); gs.alignment = TextAnchor.MiddleRight; GUIStyle texFieldGS = new GUIStyle(GUI.skin.textField); Color errorColor = new Color(1, 0, 0); Color normalColor = texFieldGS.normal.textColor; float dummyFloat; GUI.Label( new Rect(10, y, 65, 25), "Altitude: ", gs); if (float.TryParse(altitude.AltitudeS, out dummyFloat)) { texFieldGS.normal.textColor = normalColor; texFieldGS.hover.textColor = normalColor; texFieldGS.active.textColor = normalColor; texFieldGS.focused.textColor = normalColor; } else { texFieldGS.normal.textColor = errorColor; texFieldGS.hover.textColor = errorColor; texFieldGS.active.textColor = errorColor; texFieldGS.focused.textColor = errorColor; } String sAltitude = GUI.TextField(new Rect(80, y, 50, 25), altitude.AltitudeS, texFieldGS); float fAltitude = GUI.HorizontalSlider(new Rect(135, y + 5, 115, 25), altitude.AltitudeF, 0, 22000); altitude.Update(fAltitude, sAltitude); return y + 30; }