Example #1
0
        private void showFloatEditor(string text, ref WipValue wipValue, ref float value, ref GameConfig config, bool ownHoriztonal)
        {
            if (ownHoriztonal)
            {
                GUILayout.BeginHorizontal();
            }
            GUILayout.Label(text + " : " + ((!wipValue.valid && wipValue.value != null) ? "(" + value + ")" : ""));
            if (ownHoriztonal)
            {
                GUILayout.FlexibleSpace();
            }

            if (wipValue.value == null)
            {
                wipValue.value = value.ToString();
            }
            wipValue.value = GUILayout.TextField(wipValue.value, GUILayout.Width(40));

            float tempValue;

            wipValue.valid = float.TryParse(wipValue.value, out tempValue);

            if (ownHoriztonal)
            {
                GUILayout.EndHorizontal();
            }

            if (wipValue.valid)
            {
                value = tempValue;
                if (config.validate())
                {
                    wipValue.value = null;
                }
            }
        }
        private void showFloatEditor(string text, ref WipValue wipValue, ref float value, ref GameConfig config, bool ownHoriztonal)
        {
            if (ownHoriztonal) GUILayout.BeginHorizontal();
            GUILayout.Label(text + " : " + ((!wipValue.valid && wipValue.value != null) ? "(" + value + ")" : ""));
            if (ownHoriztonal) GUILayout.FlexibleSpace();

            if (wipValue.value == null)
            {
                wipValue.value = value.ToString();
            }
            wipValue.value = GUILayout.TextField(wipValue.value, GUILayout.Width(40));

            float tempValue;
            wipValue.valid = float.TryParse(wipValue.value, out tempValue);

            if (ownHoriztonal) GUILayout.EndHorizontal();

            if (wipValue.valid)
            {
                value = tempValue;
                if (config.validate())
                {
                    wipValue.value = null;
                }
            }
        }