public static bool DrawTitlebar(Rect position, GUIContent content, bool foldout, Action onSettingsOpen = null, Object[] targets = null) { var styles = GetStyles(); var sizeHelp = styles.IconButton.CalcSize(styles.HelpIcon); var sizePreset = styles.IconButton.CalcSize(styles.PresetIcon); var sizeSettings = styles.IconButton.CalcSize(styles.SettingsIcon); var rectFoldout = new Rect(position.x, position.y + 2F, position.width - sizeSettings.x, position.height); var rectHelp = new Rect(position.x + position.width - sizeSettings.x - sizePreset.x - sizeHelp.x, position.y + 2F, sizeHelp.x, sizeHelp.y); var rectPreset = new Rect(position.x + position.width - sizeSettings.x - sizePreset.x, position.y + 2F, sizePreset.x, sizePreset.y); var rectSettings = new Rect(position.x + position.width - sizeSettings.x, position.y + 2F, sizeSettings.x, sizeSettings.y); DrawTitlebarBackground(position); if (targets != null) { rectFoldout.width -= sizePreset.x + sizeHelp.x; if (GUI.Button(rectHelp, styles.HelpIcon, styles.IconButton)) { Help.ShowHelpForObject(targets[0]); } PresetSelector.DrawPresetButton(rectPreset, targets); } if (GUI.Button(rectSettings, styles.SettingsIcon, styles.IconButton)) { onSettingsOpen?.Invoke(); } return(DrawTitlebarFoldout(rectFoldout, content, foldout, onSettingsOpen)); }
static void newGUI() { if (EditorWindow.focusedWindow == window) { rect = EditorWindow.focusedWindow.rootVisualElement.layout; } else { rect = root.layout; } GUILayout.Box(new GUIContent("Voxel Tool"), GUILayout.ExpandWidth(true), GUILayout.Height(20)); PresetSelector.DrawPresetButton(new Rect(new Vector2(rect.position.x + rect.width - 20, 2), new Vector2(10, 10)), presetTarget); }
public override void OnTitleBarGUI() { const int upperMargin = 6, rightMargin = 2; var rect = GUILayoutUtility.GetRect(helpIcon, GUIStyles.IconButton); rect.y = upperMargin; rect.x -= rightMargin; PresetSelector.DrawPresetButton(rect, assetTargets); rect.x -= rect.width + rightMargin; if (GUI.Button(rect, helpIcon, GUIStyles.IconButton)) { Application.OpenURL($"https://naninovel.com/{HelpUri}"); } }