/// <summary> /// Used to draw all our settings for forges. /// </summary> /// <param name="style"></param> protected override void DrawWidgetContent(ScriptForgeStyles style) { m_AutomaticallyGenerate = EditorGUILayout.Toggle(ScriptForgeLabels.autoBuildContent, m_AutomaticallyGenerate); GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); { EditorGUILayout.LabelField(ScriptForgeLabels.scriptLocation, new GUIContent(m_ScriptLocation), EditorStyles.textField); } EditorGUI.EndDisabledGroup(); if (GUILayout.Button(ScriptForgeLabels.changePathContent, style.changePathButton)) { string buildPath = EditorUtility.SaveFilePanelInProject("Save Location", defaultName, "cs", "Where would you like to save this class?"); if (!string.IsNullOrEmpty(buildPath)) { m_ScriptLocation = buildPath; ClearError(ScriptForgeErrors.Codes.Script_Location_Not_Defined); } } } GUILayout.EndHorizontal(); m_Namespace = EditorGUILayoutEx.NamespaceTextField(ScriptForgeLabels.namespaceContent, m_Namespace); m_ClassName = EditorGUILayoutEx.ClassNameTextField(ScriptForgeLabels.classNameContent, m_ClassName, defaultName); }
/// <summary> /// Draws the buttons for th bottom of the widget. By default we have three buttons. Generate, Reset, and Remove. /// </summary> /// <param name="style">The style we use to draw our butons.</param> protected override void DrawWidgetFooter(ScriptForgeStyles style) { GUILayout.BeginHorizontal(); { if (GUILayout.Button(ScriptForgeLabels.forceGenerateForgeButton, style.miniButtonLeftIcon)) { GenerateForge(true); } if (GUILayout.Button(ScriptForgeLabels.generateForgeButton, style.miniButtonMiddle)) { GenerateForge(false); } if (GUILayout.Button(ScriptForgeLabels.resetForgeButton, style.miniButtonMiddle)) { OnReset(); } if (GUILayout.Button(ScriptForgeLabels.removeForgeButton, style.miniButtonRight)) { OnRemove(); } } GUILayout.EndHorizontal(); }
protected override void DrawWidgetFooter(ScriptForgeStyles style) { GUILayout.BeginHorizontal(); { if (GUILayout.Button(ScriptForgeLabels.documentationButtonLabel, style.fontAwesomeButton)) { ExtenalLinks.OpenDocumentationPage(); } if (GUILayout.Button(ScriptForgeLabels.issuesButtonLabel, style.fontAwesomeButton)) { ExtenalLinks.OpenIssuesPage(); } if (GUILayout.Button(ScriptForgeLabels.licenseButtonLabel, style.fontAwesomeButton)) { ExtenalLinks.OpenLicense(); } if (GUILayout.Button(ScriptForgeLabels.repoButtonLabel, style.fontAwesomeButton)) { ExtenalLinks.OpenRepoPage(); } if (GUILayout.Button(ScriptForgeLabels.twitterButtonLabel, style.fontAwesomeButton)) { ExtenalLinks.OpenTwitter(); } } GUILayout.EndHorizontal(); }
protected override void DrawWidgetFooter(ScriptForgeStyles style) { if (GUILayout.Button("Documentation", style.button)) { ScriptableForge.OpenDocumentation(); } }
/// <summary> /// Invoked to allow us to draw are GUI content for this forge. /// </summary> protected override void DrawWidgetContent(ScriptForgeStyles style) { base.DrawWidgetContent(style); m_GenerateClipNames = EditorGUILayout.Toggle(ScriptForgeLabels.generateClipNamesLabel, m_GenerateClipNames); m_GenerateLayerNames = EditorGUILayout.Toggle(ScriptForgeLabels.generateLayerNamesLabel, m_GenerateLayerNames); m_GenerateParamaters = EditorGUILayout.Toggle(ScriptForgeLabels.generateParamatersLabel, m_GenerateParamaters); m_DataReorderableList.DoLayoutList(); }
protected override void DrawWidgetContent(ScriptForgeStyles style) { base.DrawWidgetContent(style); // Draw our folders if (m_FoldersDrawer != null) { m_FoldersDrawer.DoLayoutList(); } }
/// <summary> /// Callback used to draw GUI in the title bar. /// </summary> public virtual void OnTitleBarGUI(ScriptForgeStyles style) { GUILayout.Label(iconString, style.widgetHeaderIcon); GUILayout.Label(label, style.widgetHeaderText); GUILayout.Space(10); if (m_InDevelopment) { GUILayout.Label(ScriptForgeLabels.inDevelopmentIcon, style.widgetHeaderIcon); } }
/// <summary> /// All drawing logic is placed inside of this method. /// </summary> public virtual void OnWidgetGUI(ScriptForgeStyles style) { GUI.backgroundColor = m_BackgroundColor; Rect headerRect = EditorGUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { OnTitleBarGUI(style); } GUILayout.EndHorizontal(); headerRect.height = 30f; if (Event.current.type == EventType.MouseDown && headerRect.Contains(Event.current.mousePosition)) { FlashColor(Color.gray, 0.25f); m_IsOpen = !m_IsOpen; GUIUtility.hotControl = -1; GUIUtility.keyboardControl = -1; } if (EditorGUILayout.BeginFadeGroup(m_OpenAnimation.faded)) { GUILayout.Box(GUIContent.none, style.spacer); if (m_ErrorCode != ScriptForgeErrors.Codes.None) { EditorGUILayout.HelpBox(m_ErrorMessage, MessageType.Error); } EditorGUI.BeginChangeCheck(); { DrawWidgetContent(style); } if (EditorGUI.EndChangeCheck()) { OnContentChanged(); } GUILayout.Box(GUIContent.none, style.spacer); DrawWidgetFooter(style); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndVertical(); if (m_ScriptableForge.animateWidgets) { m_OpenAnimation.target = m_IsOpen; } else { m_OpenAnimation.value = m_IsOpen; } GUI.backgroundColor = Color.white; }
protected override void DrawWidgetContent(ScriptForgeStyles style) { m_ScriptableForge.animateWidgets = EditorGUILayout.Toggle(ScriptForgeLabels.animateWidgetsContent, m_ScriptableForge.animateWidgets); EditorGUI.BeginChangeCheck(); { m_ScriptableForge.indentCount = EditorGUILayout.IntSlider(ScriptForgeLabels.indentCountLabel, m_ScriptableForge.indentCount, MIN_INDENT_SIZE, MAX_INDENT_SIZE); } if (EditorGUI.EndChangeCheck()) { // Force users to give a valid input. They could type in a negative number which would throw an exception in the generation process. m_ScriptableForge.indentCount = Mathf.Clamp(m_ScriptableForge.indentCount, MIN_INDENT_SIZE, MAX_INDENT_SIZE); } }
/// <summary> /// Used to draw all our settings for forges. /// </summary> /// <param name="style"></param> protected override void DrawWidgetContent(ScriptForgeStyles style) { m_AutomaticallyGenerate = EditorGUILayout.Toggle(ScriptForgeLabels.autoBuildContent, m_AutomaticallyGenerate); GUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(ScriptForgeLabels.scriptLocation.text, m_ScriptLocation, EditorStyles.objectField); // Get the rect for our field so we can make our button Rect fieldRect = GUILayoutUtility.GetLastRect(); // Resize it so we can have the click event only happen on the right. fieldRect.x += fieldRect.width - SCRIPT_LOCATION_BUTTON_WIDTH; fieldRect.width = SCRIPT_LOCATION_BUTTON_WIDTH; // Cache our current event Event @event = Event.current; // Check for a click event if (@event.button == 0 && // Left mouse button @event.type == EventType.MouseDown && // We are a press events (instead of a move event) fieldRect.Contains(@event.mousePosition)) // We clicked our our button area. { string buildPath = EditorUtility.SaveFilePanelInProject(ScriptForgeLabels.ScriptSaveLocation.title, defaultName, ScriptForgeLabels.ScriptSaveLocation.extension, ScriptForgeLabels.ScriptSaveLocation.message); if (!string.IsNullOrEmpty(buildPath)) { m_ScriptLocation = buildPath; ClearError(ScriptForgeErrors.Codes.Script_Location_Not_Defined); } } } GUILayout.EndHorizontal(); m_Namespace = EditorGUILayoutEx.NamespaceTextField(ScriptForgeLabels.namespaceContent, m_Namespace); m_ClassName = EditorGUILayoutEx.ClassNameTextField(ScriptForgeLabels.classNameContent, m_ClassName, defaultName); for (int i = 0; i < m_Components.Count; i++) { EditorGUI.BeginChangeCheck(); { m_Components[i].DrawContent(style); } if (EditorGUI.EndChangeCheck()) { // Since components are sub objects we need to force tell them they are dirty // or we will not save. EditorUtility.SetDirty(m_Components[i]); } } }
public override void OnTitleBarGUI(ScriptForgeStyles style) { base.OnTitleBarGUI(style); GUILayout.FlexibleSpace(); if (errorCode != ScriptForgeErrors.Codes.None) { GUILayout.Label(FontAwesomeIcons.WARNING, style.widgetHeaderIcon); } else if (m_IsUpToDate) { GUILayout.Label(FontAwesomeIcons.CHECKBOX, style.widgetHeaderIcon); } else { GUILayout.Label(FontAwesomeIcons.REFRESH, style.widgetHeaderIcon); } }
/// <summary> /// Draws the header for our instance. /// </summary> protected override void OnHeaderGUI() { if (m_Styles == null) { m_Styles = new ScriptForgeStyles(); } GUILayout.Space(10); GUILayout.BeginHorizontal("ShurikenEffectBg"); { GUILayout.Box(GUIContent.none, m_Styles.scriptForgeIconSmall); GUILayout.Label(ScriptForgeLabels.HEADER_TITLE, m_Styles.title); GUILayout.Label(ScriptForgeLabels.HEADER_SUB_TITLE, m_Styles.subTitle); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.Box(FontAwesomeIcons.INFO, GUIStyle.none); }
/// <summary> /// Draws the title of the widget and it's icons. /// </summary> /// <param name="style">The style we use to draw it's content.</param> public override void OnTitleBarGUI(ScriptForgeStyles style) { base.OnTitleBarGUI(style); GUILayout.FlexibleSpace(); if (errorCode != ScriptForgeErrors.Codes.None) { GUILayout.Label(ScriptForgeLabels.forgeErrorIcon, style.widgetHeaderIcon); } else if (m_IsUpToDate) { GUILayout.Label(ScriptForgeLabels.forgeUpToDateIcon, style.widgetHeaderIcon); } else { GUILayout.Label(ScriptForgeLabels.forgeOutOfDateIcon, style.widgetHeaderIcon); } }
/// <summary> /// Draws the header for script forge. /// </summary> private void DrawButtons() { using (new GUILayout.VerticalScope()) { DrawSpacer(); if (m_Styles == null) { m_Styles = new ScriptForgeStyles(); } if (GUILayout.Button(ScriptForgeLabels.generateAllForgesLabel, m_Styles.button)) { for (int i = 0; i < m_Target.Widgets.Count; i++) { m_Target.Widgets[i].OnGenerate(false); } } using (new GUILayout.HorizontalScope()) { DrawAddForgeButton(); if (GUILayout.Button(ScriptForgeLabels.openAllWidgetsLabel, m_Styles.buttonMiddle)) { for (int i = 0; i < m_Target.Widgets.Count; i++) { m_Target.Widgets[i].isOpen = true; } } if (GUILayout.Button(ScriptForgeLabels.closeAllWidgetsLabel, m_Styles.buttonRight)) { for (int i = 0; i < m_Target.Widgets.Count; i++) { m_Target.Widgets[i].isOpen = false; } } } GUILayout.Space(5.0f); } }
protected virtual void DrawWidgetFooter(ScriptForgeStyles style) { }
protected virtual void DrawWidgetContent(ScriptForgeStyles style) { GUILayout.Label("The content has not been set up yet"); }
/// <summary> /// Callback used to draw GUI in the title bar. /// </summary> public virtual void OnTitleBarGUI(ScriptForgeStyles style) { GUILayout.Label(iconString, style.widgetHeaderIcon); GUILayout.Label(label, style.widgetHeaderText); }
/// <summary> /// All drawing logic is placed inside of this method. /// </summary> public virtual void OnWidgetGUI(ScriptForgeStyles style) { GUI.backgroundColor = m_BackgroundColor; Rect headerRect = EditorGUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { OnTitleBarGUI(style); } GUILayout.EndHorizontal(); headerRect.height = 30f; if (Event.current.type == EventType.MouseDown && headerRect.Contains(Event.current.mousePosition)) { // They left clicked. if (Event.current.button == 0) { FlashColor(Color.gray, 0.25f); m_IsOpen = !m_IsOpen; GUIUtility.hotControl = -1; GUIUtility.keyboardControl = -1; } // They right clicked. else if (Event.current.button == 1) { // Create our menu. GenericMenu menu = new GenericMenu(); // Populate it OnGenerateContexMenu(menu); // Check if we have any elements if (menu.GetItemCount() > 0) { // Show it. menu.DropDown(headerRect); } } } // As long as our animation is playing we // want to force a repaint. if (m_OpenAnimation.isAnimating) { m_ScriptableForge.Repaint(); } if (EditorGUILayout.BeginFadeGroup(m_OpenAnimation.faded)) { GUILayout.Box(GUIContent.none, style.spacer); if (m_ErrorCode != ScriptForgeErrors.Codes.None) { EditorGUILayout.HelpBox(m_ErrorMessage, MessageType.Error); } EditorGUI.BeginChangeCheck(); { DrawWidgetContent(style); } if (EditorGUI.EndChangeCheck()) { OnContentChanged(); } GUILayout.Box(GUIContent.none, style.spacer); DrawWidgetFooter(style); } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndVertical(); if (m_ScriptableForge.animateWidgets) { m_OpenAnimation.target = m_IsOpen; } else { m_OpenAnimation.value = m_IsOpen; } GUI.backgroundColor = Color.white; }
/// <summary> /// Invoked when this widget should draws it's bottom content. /// </summary> /// <param name="style">The style we use to draw our content.</param> protected virtual void DrawWidgetFooter(ScriptForgeStyles style) { // Nothing to do here }
protected override void DrawWidgetContent(ScriptForgeStyles style) { EditorGUILayout.LabelField(ScriptForgeLabels.aboutWidgetContent, EditorStyles.wordWrappedLabel); }
/// <summary> /// Invoked to allow us to draw are GUI content for this forge. /// </summary> protected override void DrawWidgetContent(ScriptForgeStyles style) { base.DrawWidgetContent(style); m_CreateBitwise = EditorGUILayout.Toggle(ScriptForgeLabels.createBitwiseLabel, m_CreateBitwise); }
protected override void DrawWidgetContent(ScriptForgeStyles style) { m_ScriptableForge.animateWidgets = EditorGUILayout.Toggle(ScriptForgeLabels.animateWidgetsContent, m_ScriptableForge.animateWidgets); }
protected override void DrawWidgetFooter(ScriptForgeStyles style) { }
/// <summary> /// Invoked to allow us to draw are GUI content for this forge. /// </summary> protected override void DrawWidgetContent(ScriptForgeStyles style) { base.DrawWidgetContent(style); }
protected override void DrawWidgetContent(ScriptForgeStyles style) { base.DrawWidgetContent(style); m_EnumName = EditorGUILayoutEx.ClassNameTextField(ScriptForgeLabels.enumNameContent, m_EnumName, "Types"); }