public static void CreateComment() { var go = new GameObject("Comment", typeof(SceneComment)); if (Selection.activeGameObject != null && Selection.activeGameObject.scene != null) { go.transform.parent = Selection.activeGameObject.transform; } if (SceneView.lastActiveSceneView != null) { var cam = SceneView.lastActiveSceneView.camera; go.transform.position = cam.transform.position; go.transform.rotation = cam.transform.rotation; } Selection.activeGameObject = go; go.GetComponent <SceneComment>().SetDefault(); SceneCommentEditor.RequestEdit(); }
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(); }