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(); } }
private void OnGUI() { var color = GUI.color; var labelWidth = EditorGUIUtility.labelWidth; EditorGUILayout.Separator(); using (new EditorGUILayout.HorizontalScope()) { using (new EditorGUILayout.VerticalScope(GUILayout.MaxWidth(isShowingSideBar ? 100f : 12f))) { isShowingSideBar = EditorGUILayout.ToggleLeft("SHOW SIDEBAR", isShowingSideBar); if (isShowingSideBar) { DrawSideBar(); } } if (isShowingSideBar) { GUILayout.Box(EditorGUIUtility.whiteTexture, GUILayout.ExpandHeight(true), GUILayout.Width(1f)); } using (new EditorGUILayout.VerticalScope()) { if (DrawSelectedThread()) { CommentStatics.registry.threads.Remove(selectedThread); selectedThread = null; SceneView.RepaintAll(); } } } GUI.color = color; EditorGUIUtility.labelWidth = labelWidth; }
public static CommentThread NewThread() { var scene = SceneManager.GetActiveScene().path; if (string.IsNullOrEmpty(scene)) { EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); scene = SceneManager.GetActiveScene().path; if (string.IsNullOrEmpty(scene)) { return(null); } } var thread = new CommentThread(); thread.scene = scene; thread.SetPositionViaRaycast(); registry.threads.Add(thread); AssetDatabase.SaveAssets(); return(thread); }