/// <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> /// 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]); } } }