Esempio n. 1
0
        private void DrawSideBar()
        {
            EditorGUI.BeginChangeCheck();
            var color = GUI.color;

            GUI.color = Color.green;
            if (GUILayout.Button("Create New Thread"))
            {
                var newThread = CommentStatics.NewThread();
                selectedThread = newThread == null ? selectedThread : newThread;
                selectedThread.FocusView();
            }
            GUI.color        = color;
            isShowing        = EditorGUILayout.Toggle("Show Comments", isShowing);
            isShowingPreview = EditorGUILayout.Toggle("Show Preview", isShowingPreview);
            foreach (var t in CommentStatics.registry.threads)
            {
                if (GUILayout.Button(t.threadTitle))
                {
                    selectedThread = t;
                    selectedThread.FocusView();
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
        }
Esempio n. 2
0
        private bool DrawSelectedThread()
        {
            if (selectedThread == null)
            {
                return(false);
            }
            EditorGUIUtility.labelWidth = 60f;
            EditorGUILayout.Separator();
            EditorGUI.BeginChangeCheck();
            selectedThread.threadTitle = EditorGUILayout.TextField("Thread: ", selectedThread.threadTitle);
            selectedThread.color       = EditorGUILayout.ColorField("Color: ", selectedThread.color);
            var color = GUI.color;

            GUI.color = Color.red;
            if (GUILayout.Button("Delete"))
            {
                return(true);
            }
            GUI.color = color;
            if (GUILayout.Button("Raycast New Position"))
            {
                selectedThread.SetPositionViaRaycast();
                selectedThread.FocusView();
            }
            var width = EditorGUIUtility.currentViewWidth - 40f;

            using (var scroll = new EditorGUILayout.ScrollViewScope(threadScrollPosition))
            {
                using (new EditorGUILayout.VerticalScope(GUILayout.MaxWidth(width)))
                {
                    foreach (var c in selectedThread.thread)
                    {
                        using (new EditorGUILayout.VerticalScope())
                        {
                            EditorGUILayout.LabelField("User: "******"Date: ", DateTime.FromBinary(c.date).ToLocalTime().ToString(), EditorStyles.boldLabel);
                            EditorGUILayout.SelectableLabel(c.commentText, GUILayout.Height(EditorStyles.label.CalcHeight(new GUIContent(c.commentText), width)));
                        }
                        EditorGUILayout.Separator();
                    }
                }
                threadScrollPosition = scroll.scrollPosition;
            }
            var textAreaWW = new GUIStyle(EditorStyles.textArea);

            textAreaWW.wordWrap = true;
            using (new EditorGUILayout.VerticalScope())
            {
                {
                    const int LIMIT = 1000;
                    if (text.Length > LIMIT)
                    {
                        text = text.Substring(0, LIMIT);
                        EditorGUIUtility.editingTextField = false;
                    }
                    EditorGUILayout.LabelField(string.Format("{0}/{1}", text.Length, LIMIT));
                    text = EditorGUILayout.TextArea(text, textAreaWW, GUILayout.Height(50f));

                    if (GUILayout.Button("Add Comment"))
                    {
                        selectedThread.AddComment(text);
                        text = string.Empty;
                    }
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
            return(false);
        }