private static object EnumField(string id, string name, object value) { GUILayout.BeginHorizontal(); try { var enumType = value.GetType(); if (!string.IsNullOrEmpty(name)) { GUI.contentColor = Config.NameColor; GUILayout.Label(name); } GUI.contentColor = Config.ValueColor; if (TypeUtil.IsBitmaskEnum(enumType)) { GUILayout.Label(value.ToString()); } else { var names = Enum.GetNames(enumType); var values = Enum.GetValues(enumType); var valueIndex = Array.IndexOf(values, value); var newValueIndex = GUIComboBox.Box(valueIndex, names, id); if (newValueIndex != valueIndex) { value = values.GetValue(newValueIndex); } } GUI.contentColor = Color.white; } finally { GUILayout.EndHorizontal(); } return(value); }
private static object ShaderField(string id, Shader value) { GUILayout.BeginHorizontal(); try { GUI.contentColor = Config.ValueColor; var values = ShaderUtil.GetShaders(); var valueIndex = Array.IndexOf(values, value.name); var newValueIndex = GUIComboBox.Box(valueIndex, values, id); if (newValueIndex != valueIndex) { value = Shader.Find(values[newValueIndex]); } GUI.contentColor = Color.white; } finally { GUILayout.EndHorizontal(); } return(value); }