Quantcast
Channel: Latest Questions by Yanger_xy
Viewing all articles
Browse latest Browse all 61

How to input float in textfiled and and let the scrollbar change its value at the same time

$
0
0
Hello, everyone.I wanna to draw a Scrollbar and a textfield at the same time.And when the Scrollbar scroll, the textfield's value change with it, also, when the textfield's text changed, the Scrollbar change its position too. I write the code like this: GUILayout.BeginVertical(); GUILayout.Label("目间距"); _interocularDis = GUILayout.HorizontalScrollbar(_interocularDis, 0.01f, 0, 1f); _interocularDis = (float)Math.Round(_interocularDis, digit1); string textInterocular = GUILayout.TextField(_interocularDis.ToString()); try { _interocularDis = (float)Math.Round(_interocularDis, digit1); //float tmp = float.Parse(textInterocular, System.Globalization.NumberStyles.AllowDecimalPoint); float tmp = 0.0f; float.TryParse(textInterocular, out tmp); _interocularDis = tmp; // _interocularDis = (float)Convert.ToDouble(textInterocular); } catch (Exception e) { } } GUILayout.EndVertical(); However, i can not input a float number in the textfield, how can i input a float number in the textfield and let the scrollbar change its value at the same time? Any answer will be appreciate!

Viewing all articles
Browse latest Browse all 61

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>