Beispiel #1
0
        void UpdateComment()
        {
            if (m_Comment == null)
            {
                m_Comment = serializedObject.FindProperty("m_Comment");
            }

            if (m_CommentEditor == null)
            {
                m_CommentEditor = new CommentEditor(serializedObject, m_Comment);
            }

            sceneComment = (serializedObject.targetObject as SceneComment);
        }
        void UpdateComment()
        {
            if (m_Comment == null)
            {
                m_Comment = serializedObject.FindProperty("m_Comment");
            }

            if (m_CommentEditor == null)
            {
                m_CommentEditor = new CommentEditor(serializedObject, m_Comment, true);
            }

            commentAsset = (serializedObject.targetObject as CommentAsset);

            if (commentAsset.firstTimeEdit)
            {
                RequestEdit();
            }
        }
        bool DrawComment(Comment comment, int index, UnityEngine.Object parent)
        {
            if (comment.computedState == CommentState.Open && !GetShowPref(CommentState.Open))
            {
                return(false);
            }
            if (comment.computedState == CommentState.Resolved && !GetShowPref(CommentState.Resolved))
            {
                return(false);
            }
            if (comment.computedState == CommentState.Blocked && !GetShowPref(CommentState.Blocked))
            {
                return(false);
            }
            if (comment.computedState == CommentState.WontFix && !GetShowPref(CommentState.WontFix))
            {
                return(false);
            }
            if (comment.computedState == CommentState.Closed && !GetShowPref(CommentState.Closed))
            {
                return(false);
            }

            if (comment.computedType == CommentType.Bug && !GetShowPref(CommentType.Bug))
            {
                return(false);
            }
            if (comment.computedType == CommentType.Info && !GetShowPref(CommentType.Info))
            {
                return(false);
            }
            if (comment.computedType == CommentType.Request && !GetShowPref(CommentType.Request))
            {
                return(false);
            }
            if (comment.computedType == CommentType.ToDo && !GetShowPref(CommentType.ToDo))
            {
                return(false);
            }

            if (comment.computedPriority == CommentPriority.High && !GetShowPref(CommentPriority.High))
            {
                return(false);
            }
            if (comment.computedPriority == CommentPriority.Medium && !GetShowPref(CommentPriority.Medium))
            {
                return(false);
            }
            if (comment.computedPriority == CommentPriority.Low && !GetShowPref(CommentPriority.Low))
            {
                return(false);
            }

            if (userFilter == UserFilter.MyComments && !comment.users.Contains(user))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(searchFilter) && !MatchFilter(parent, comment, searchFilter))
            {
                return(false);
            }

            GUI.backgroundColor = (index % 2 == 0) ? Color.white : Color.white * 0.9f;
            using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
            {
                if (GUILayout.Button(CommentEditor.GetPriorityContent(comment.title, comment.computedPriority), Styles.line, GUILayout.Width(180)))
                {
                    Selection.activeObject = parent;
                }

                GUILayout.Label(comment.message.body, Styles.line, GUILayout.Width(position.width - 541));
                if (parent is GameObject)
                {
                    GUILayout.Label((parent as GameObject).scene.name, Styles.line, GUILayout.Width(100));
                }
                else
                {
                    GUILayout.Label((parent as CommentAsset).name, Styles.line, GUILayout.Width(100));
                }

                GUILayout.Label(comment.message.from, Styles.line, GUILayout.Width(80));
                GUILayout.Label(comment.computedType.ToString(), Styles.line, GUILayout.Width(50));
                GUILayout.Label(comment.computedPriority.ToString(), Styles.line, GUILayout.Width(60));
                GUILayout.Label(comment.computedState.ToString(), Styles.line, GUILayout.Width(70));
            }
            return(true);
        }
Beispiel #4
0
        public void DrawComment(Comment comment, bool requireEdit = false)
        {
            if (requireEdit)
            {
                editMessagePath = rootMessage.propertyPath;
                requireEdit     = false;
            }

            using (new GUILayout.HorizontalScope())
            {
                TypeLabel(comment.computedType);
                StateLabel(comment.computedState);
                PriorityLabel(comment.computedPriority);

                GUILayout.FlexibleSpace();
                EditorGUI.BeginChangeCheck();
                EditorGUI.BeginDisabledGroup(comment.message.from != CommentsWindow.user);
                bool editRoot = DrawEditButton(this.editRoot);
                EditorGUI.EndDisabledGroup();
                if (EditorGUI.EndChangeCheck())
                {
                    if (editRoot)
                    {
                        editMessagePath = rootMessage.propertyPath;
                    }
                    else
                    {
                        editMessagePath = string.Empty;
                    }
                }
            }

            GUILayout.Space(6);

            if (editRoot)
            {
                serializedObject.Update();
                EditorGUILayout.PropertyField(title);
                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.PropertyField(focus);

                    if (!m_IsAsset && GUILayout.Button("Align to SceneView", GUILayout.ExpandWidth(true)))
                    {
                        focus.boolValue = true;
                        if (SceneView.lastActiveSceneView != null)
                        {
                            SceneComment c = serializedObject.targetObject as SceneComment;
                            c.gameObject.transform.position = SceneView.lastActiveSceneView.camera.transform.position;
                            c.gameObject.transform.rotation = SceneView.lastActiveSceneView.camera.transform.rotation;
                        }
                    }
                }
                serializedObject.ApplyModifiedProperties();
                CommentsWindow.RequestRefresh();
            }
            else
            {
                GUILayout.Space(8);

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Label(CommentEditor.GetPriorityContent(" " + title.stringValue, comment.computedPriority), Styles.title);
                    GUILayout.FlexibleSpace();
                }
            }

            GUILayout.Space(6);
            DrawMessage(rootMessage, -1);
            int replyCount = replies.arraySize;

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(16);
                using (new GUILayout.VerticalScope())
                {
                    for (int i = 0; i < replyCount; i++)
                    {
                        DrawMessage(replies.GetArrayElementAtIndex(i), i);
                    }
                }
            }
        }
        private void OnGUI()
        {
            // Toolbar
            using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
            {
                if (GUILayout.Button("+", EditorStyles.toolbarButton, GUILayout.Width(24)))
                {
                    SceneCommentEditor.CreateComment();
                    Refresh();
                }

                if (GUILayout.Button(EditorGUIUtility.IconContent("Refresh"), EditorStyles.toolbarButton, GUILayout.Width(24)))
                {
                    Refresh();
                }

                searchFilter = EditorGUILayout.DelayedTextField(searchFilter, EditorStyles.toolbarSearchField, GUILayout.ExpandWidth(true));
                userFilter   = (UserFilter)EditorGUILayout.EnumPopup(userFilter, EditorStyles.toolbarDropDown, GUILayout.Width(128));
                if (GUILayout.Button("Type", EditorStyles.toolbarDropDown, GUILayout.Width(64)))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent(CommentType.Bug.ToString()), GetShowPref(CommentType.Bug), MenuToggleShowPref, CommentType.Bug);
                    menu.AddItem(new GUIContent(CommentType.Info.ToString()), GetShowPref(CommentType.Info), MenuToggleShowPref, CommentType.Info);
                    menu.AddItem(new GUIContent(CommentType.Request.ToString()), GetShowPref(CommentType.Request), MenuToggleShowPref, CommentType.Request);
                    menu.AddItem(new GUIContent(CommentType.ToDo.ToString()), GetShowPref(CommentType.ToDo), MenuToggleShowPref, CommentType.ToDo);
                    menu.DropDown(new Rect(position.width - 240, 10, 12, 12));
                }
                if (GUILayout.Button("State", EditorStyles.toolbarDropDown, GUILayout.Width(64)))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent(CommentState.Open.ToString()), GetShowPref(CommentState.Open), MenuToggleShowPref, CommentState.Open);
                    menu.AddItem(new GUIContent(CommentState.Resolved.ToString()), GetShowPref(CommentState.Resolved), MenuToggleShowPref, CommentState.Resolved);
                    menu.AddItem(new GUIContent(CommentState.Closed.ToString()), GetShowPref(CommentState.Closed), MenuToggleShowPref, CommentState.Closed);
                    menu.AddItem(new GUIContent(CommentState.WontFix.ToString()), GetShowPref(CommentState.WontFix), MenuToggleShowPref, CommentState.WontFix);
                    menu.AddItem(new GUIContent(CommentState.Blocked.ToString()), GetShowPref(CommentState.Blocked), MenuToggleShowPref, CommentState.Blocked);
                    menu.DropDown(new Rect(position.width - 176, 10, 12, 12));
                }
                GUILayout.Space(16);

                EditorGUI.BeginChangeCheck();
                bool showHigh   = GUILayout.Toggle(GetShowPref(CommentPriority.High), CommentEditor.GetPriorityContent(highCount.ToString(), CommentPriority.High), EditorStyles.toolbarButton, GUILayout.Width(32));
                bool showMedium = GUILayout.Toggle(GetShowPref(CommentPriority.Medium), CommentEditor.GetPriorityContent(mediumCount.ToString(), CommentPriority.Medium), EditorStyles.toolbarButton, GUILayout.Width(32));
                bool showLow    = GUILayout.Toggle(GetShowPref(CommentPriority.Low), CommentEditor.GetPriorityContent(lowCount.ToString(), CommentPriority.Low), EditorStyles.toolbarButton, GUILayout.Width(32));
                if (EditorGUI.EndChangeCheck())
                {
                    SetShowPref(CommentPriority.High, showHigh);
                    SetShowPref(CommentPriority.Medium, showMedium);
                    SetShowPref(CommentPriority.Low, showMedium);
                }
            }

            GUI.backgroundColor = Color.white * 1.25f;

            // Header
            using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
            {
                SortButton("Commment", SortMode.Name, 180);
                SortButton("Description", SortMode.Description, position.width - 541);
                SortButton("Location", SortMode.Location, 100);
                SortButton("From", SortMode.From, 80);
                SortButton("Type", SortMode.Type, 50);
                SortButton("Priority", SortMode.Priority, 60);
                SortButton("State", SortMode.State, 70);
            }
            GUI.backgroundColor = Color.white;
            scrollPosition      = EditorGUILayout.BeginScrollView(scrollPosition);



            int i = 0;

            // Lines
            foreach (var comment in results)
            {
                if (comment.Item2 == null)
                {
                    Refresh();
                    break;
                }

                if (comment.Item2 is SceneComment)
                {
                    if (!DrawComment(comment.Item1, i, (comment.Item2 as SceneComment).gameObject))
                    {
                        continue;
                    }
                }
                else
                {
                    if (!DrawComment(comment.Item1, i, comment.Item2 as CommentAsset))
                    {
                        continue;
                    }
                }
                i++;
            }

            EditorGUILayout.EndScrollView();
        }