void DrawOption(Sensor sensor, IOption opt) { if (!cachedValue.ContainsKey(opt)) { cachedValue[opt] = opt.Value; } string k = opt.Key.ToString(); float v = cachedValue[opt]; if (opt.ReadOnly) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(k, GUILayout.Width(EditorGUIUtility.labelWidth - 4)); EditorGUILayout.SelectableLabel(v.ToString(), EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); EditorGUILayout.EndHorizontal(); } else if (opt.IsCheckbox()) { bool isChecked = Convert.ToBoolean(v); if (isChecked != EditorGUILayout.Toggle(k, isChecked)) { cachedValue[opt] = opt.Value = Convert.ToSingle(!isChecked); } } else if (opt.IsEnum(sensor.Options)) { var valuesStrings = new List <string>(); int selected = 0; int counter = 0; for (float i = opt.Min; i <= opt.Max; i += opt.Step, counter++) { if (Math.Abs(i - v) < 0.001) { selected = counter; } valuesStrings.Add(sensor.Options.OptionValueDescription(opt.Key, i)); } var newSelection = EditorGUILayout.Popup(k, selected, valuesStrings.ToArray()); if (newSelection != selected) { cachedValue[opt] = opt.Value = Convert.ToSingle(newSelection); } } else if (opt.IsIntegersOnly()) { var newVal = EditorGUILayout.IntSlider(k, (int)v, (int)opt.Min, (int)opt.Max); if (newVal != Convert.ToInt32(v)) { cachedValue[opt] = opt.Value = Convert.ToSingle(newVal); } } else { float s = EditorGUILayout.Slider(k, v, opt.Min, opt.Max); if (!Mathf.Approximately(s, v)) { cachedValue[opt] = opt.Value = s; } } }