Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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]);
                }
            }
        }
        private void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            Rect classNameRect = rect;

            classNameRect.width /= 2.0f;
            Rect animatorRect = classNameRect;

            animatorRect.x += animatorRect.width;
            AnimatorData data = m_AnimatorsData[index];

            data.className = EditorGUILayoutEx.ClassNameTextField(classNameRect, data.className, "ClassName");
            EditorGUI.BeginChangeCheck();
            {
                data.controller = EditorGUI.ObjectField(animatorRect, data.controller, typeof(AnimatorController), false) as AnimatorController;
            }
            if (EditorGUI.EndChangeCheck())
            {
                if (string.IsNullOrEmpty(data.className) && data.controller != null)
                {
                    data.className = data.controller.name;
                }
            }
            m_AnimatorsData[index] = data;
        }
Esempio n. 4
0
 protected override void DrawWidgetContent(ScriptForgeStyles style)
 {
     base.DrawWidgetContent(style);
     m_EnumName = EditorGUILayoutEx.ClassNameTextField(ScriptForgeLabels.enumNameContent, m_EnumName, "Types");
 }