public static int Draw(this IEnumerable <string> current, int index, UnityLabel label = null, GUIStyle style = null, bool indention = true) { style = style ?? EditorStyles.popup; var labelValue = label.IsNull() ? null : label.ToString(); return(EditorUI.Draw <int>(() => EditorGUILayout.Popup(labelValue, index, current.ToArray(), style), indention)); }
public static int Draw(this IEnumerable <string> current, Rect area, int index, UnityLabel label = null, GUIStyle style = null, bool indention = true) { style = style ?? EditorStyles.popup; string name = label.IsNull() ? "" : label.ToString(); return(EditorGUIExtension.Draw <int>(() => EditorGUI.Popup(area, name, index, current.ToArray(), style), indention)); }
public static Enum DrawMask(this Enum current, Rect area, UnityLabel label = null, GUIStyle style = null, bool indention = true) { style = style ?? EditorStyles.popup; string value = current.ToName().Replace(" ", " | ").ToTitleCase(); Rect valueArea = area; if (!label.IsNull()) { Rect labelArea = area.AddWidth(-EditorGUIUtility.labelWidth); valueArea = labelArea.AddX(EditorGUIUtility.labelWidth); if (value.IsEmpty()) { value = "None"; } label.DrawLabel(labelArea, null, true); } if (GUI.Button(valueArea, value.Trim("| "), style)) { var items = current.ToName().Split(" ").ToTitleCase(); GenericMenu.MenuFunction2 callback = index => { EditorGUIExtensionSpecial.menuArea = area; EditorGUIExtensionSpecial.menuValue = current.GetValues().GetValue((int)index); }; current.GetNames().ToTitleCase().DrawMenu(valueArea, callback, items); } if (EditorGUIExtensionSpecial.menuArea == area && !EditorGUIExtensionSpecial.menuValue.IsNull()) { var menuValue = (Enum)EditorGUIExtensionSpecial.menuValue; var newValue = current.ToInt() ^ menuValue.ToInt(); current = (Enum)Enum.ToObject(current.GetType(), newValue); EditorGUIExtensionSpecial.menuValue = null; EditorGUIExtensionSpecial.menuArea = new Rect(); GUI.changed = true; } return(current); }
public static Vector4 DrawVector4(this Vector4 current, Rect area, UnityLabel label = null, bool indention = true) { string name = label.IsNull() ? null : label.ToString(); return(EditorGUIExtension.Draw <Vector3>(() => EditorGUI.Vector4Field(area, name, current), indention)); }