public static bool DisplayFoldoutElements(MaterialEditor me, string header, bool display, int buttonCount, int size) { GUIStyle formatting = GetFoldoutFormatting(); Rect rect = GUILayoutUtility.GetRect(MGUI.GetInspectorWidth(), formatting.fixedHeight, formatting); rect.width -= foldoutOffsets[buttonCount]; rect.x -= 8f; Event evt = Event.current; Color bgCol = GUI.backgroundColor; bool mouseOver = rect.Contains(evt.mousePosition); if (evt.type == EventType.MouseDown && mouseOver) { foldoutClicked = true; evt.Use(); } else if (evt.type == EventType.Repaint && foldoutClicked && mouseOver) { GUI.backgroundColor = Color.gray; me.Repaint(); } if (ContainsDigit(header)) { header = header.Substring(0, header.Length - 2); } GUI.Box(rect, header, formatting); GUI.backgroundColor = bgCol; return(FoldoutToggle(rect, evt, mouseOver, display, 0)); }
public static GUIStyle GetSubFoldoutFormatting(int buttonCount) { GUIStyle formatting = new GUIStyle("ShurikenModuleTitle"); formatting.contentOffset = new Vector2(20f, -2f); formatting.fixedHeight = 22f; formatting.fixedWidth = MGUI.GetInspectorWidth() - subFoldoutOffsets[buttonCount]; formatting.fontSize = 11; return(formatting); }
public static bool FoldoutError(string header, bool display, MaterialEditor me, Material mat, bool[] errorConds, int buttonCount) { GUIStyle formatting = new GUIStyle("ShurikenModuleTitle"); formatting.font = new GUIStyle(EditorStyles.boldLabel).font; formatting.contentOffset = new Vector2(20f, -3f); formatting.hover.textColor = Color.gray; formatting.fixedHeight = 28f; formatting.fontSize = 10; Rect rect = GUILayoutUtility.GetRect(MGUI.GetInspectorWidth(), formatting.fixedHeight, formatting); rect.width -= foldoutOffsets[buttonCount]; rect.x -= 8f; Event evt = Event.current; Color bgCol = GUI.backgroundColor; foreach (bool b in errorConds) { if (b) { GUI.backgroundColor = errorCol; break; } } bool mouseOver = rect.Contains(evt.mousePosition); if (evt.type == EventType.MouseDown && mouseOver) { foldoutClicked = true; evt.Use(); } else if (evt.type == EventType.Repaint && foldoutClicked && mouseOver) { GUI.backgroundColor = Color.gray; me.Repaint(); } if (ContainsDigit(header)) { header = header.Substring(0, header.Length - 2); } GUI.Box(rect, header, formatting); GUI.backgroundColor = bgCol; return(FoldoutToggle(rect, evt, mouseOver, display, 0)); }
public static bool MediumFoldoutError(string header, bool display, bool errorCond, int buttonCount, MaterialEditor me, Material mat) { GUIStyle formatting = new GUIStyle("ShurikenModuleTitle"); float lw = EditorGUIUtility.labelWidth; formatting.contentOffset = new Vector2(20f, -2f); formatting.fixedHeight = 22f; formatting.fixedWidth = MGUI.GetInspectorWidth() - subFoldoutOffsets[buttonCount]; formatting.fontSize = 10; Rect rect = GUILayoutUtility.GetRect(0f, 20f, formatting); rect.x -= 4f; rect.width = lw; Event evt = Event.current; Color bgCol = GUI.backgroundColor; if (errorCond) { GUI.backgroundColor = errorCol; } bool mouseOver = rect.Contains(evt.mousePosition); if (evt.type == EventType.MouseDown && mouseOver) { foldoutClicked = true; evt.Use(); } else if (evt.type == EventType.Repaint && foldoutClicked && mouseOver) { GUI.backgroundColor = Color.gray; me.Repaint(); } if (ContainsDigit(header)) { header = header.Substring(0, header.Length - 2); } GUI.Box(rect, header, formatting); GUI.backgroundColor = bgCol; return(FoldoutToggle(rect, evt, mouseOver, display, 1)); }
public static void DisplaySubFoldoutButtons(Dictionary <Action, GUIContent> buttons) { float buttonSpacing = 23f; GUILayout.BeginHorizontal(); Rect r = EditorGUILayout.GetControlRect(); r.y -= 1f; r.x += MGUI.GetInspectorWidth() + EditorGUIUtility.labelWidth + buttonSpacing + 12f; r.width = buttonSpacing; r.height = 20f; for (int i = 0; i < buttons.Count; i++) { r.x -= (buttonSpacing + 1f) * Mathf.Clamp01(i); if (GUI.Button(r, buttons.Values.ElementAt(i))) { buttons.Keys.ElementAt(i).Invoke(); } } GUILayout.EndHorizontal(); }