async private void SetSelectedGroup(int index)
        {
            await Task.Delay(10);

            _showTodoGroup = true;
            _selectedGroup = _visibleGroups[index];
            SetSelectedTodo(null);
            Repaint();
        }
        private void TodoAddGroupField()
        {
            const string defaultName = "New Asset";

            // Create new group
            if (GUILayout.Button("+", GUILayout.Height((float)TodoLayout.CreateGroupButtonHeight)))
            {
                TodoGroup group = new TodoGroup(defaultName, _currentTag ?? _config.GetTagByIndex(0));
                _data.AddGroup(ref group);
                RefreshVisibleGroups();
            }
        }
Exemple #3
0
        private void TodoAddGroupField()
        {
            const string defaultName = "New Asset";
            GUIContent   content     = new GUIContent("+", "Create a new " + (_currentTag?.name ?? "TODO") + " asset");

            // Create new group
            if (GUILayout.Button(content, GUILayout.Height((float)TodoLayout.CreateGroupButtonHeight)))
            {
                TodoGroup group = new TodoGroup(defaultName, _currentTag ?? _config.GetTagByIndex(0));
                _data.AddGroup(ref group);
                RefreshCurrentGroups();
            }
        }
Exemple #4
0
        async private void SetSelectedGroup(int index)
        {
            await Task.Delay(10);

            if (index < 0)
            {
                HideTodoGroup();
                _selectedGroup = null;
            }
            else
            {
                _showTodoGroup = true;
                _selectedGroup = _currentGroups[index];
            }
            SetSelectedTodo(null);
            Repaint();
        }
Exemple #5
0
        private static void OnPostHeaderGUI(Editor editor)
        {
            if (editor.target && _config != null &&
                _data != null && _config.inpsectorGUI)
            {
                if (!typeof(UnityEngine.Object).IsAssignableFrom(editor.target.GetType()))
                {
                    return;
                }

                if (typeof(UnityEngine.GameObject).Equals(editor.target.GetType()))
                {
                    return;
                }

                using (new HorizontalGroup())
                {
                    GUILayout.Label("TODO Tree", GUILayout.Width(Screen.width / 3f));
                    for (int i = 0; i < 2; i++)
                    {
                        GUIContent content = new GUIContent("New " + _config.tags[i].name);
                        if (GUILayout.Button(content))
                        {
                            TodoGroup newGroup;
                            if (editor.target.name.Trim().Length > 0)
                            {
                                newGroup           = new TodoGroup(editor.target.name, _config.tags[i]);
                                newGroup.reference = editor.target;
                            }
                            else
                            {
                                string   assetPath = AssetDatabase.GetAssetOrScenePath(editor.target);
                                string[] splitPath = assetPath.Split('/');
                                newGroup           = new TodoGroup(splitPath[splitPath.Length - 1].Split('.')[0], _config.tags[i]);
                                newGroup.reference = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(assetPath);
                            }
                            _data.AddGroup(ref newGroup);
                            EditorUtility.SetDirty(_data);
                            AssetDatabase.SaveAssets();
                        }
                    }
                }
            }
        }
        /** Sidebar Functions */
        private void TodoGroupField(int index)
        {
            Event     e          = Event.current;
            TodoGroup group      = _visibleGroups[index];
            GUIStyle  labelStyle = EditorStyles.label;

            // Set style depends on whether selected group
            if (_selectedGroup != null)
            {
                Color backgroundColor = group.tag.color == Color.white ? Color.black : group.tag.color;
                if (_selectedGroup == _visibleGroups[index])
                {
                    GUI.backgroundColor = backgroundColor;
                    labelStyle          = EditorStyles.boldLabel;
                }
                else
                {
                    GUI.backgroundColor = Color.white;
                }
            }

            // Show todo group
            using (new HorizontalGroup(EditorStyles.helpBox, GUILayout.Height((float)TodoLayout.TodoGroupFieldHeight)))
            {
                GUI.color = group.tag.color;

                GUILayout.Label(group.title, labelStyle, GUILayout.ExpandHeight(true));
                GUILayout.FlexibleSpace();
                GUILayout.Label("(" + group.todos.Count + ")", labelStyle, GUILayout.ExpandHeight(true));
                GUI.color           = Color.white;
                GUI.backgroundColor = Color.white;
            }

            // On clicked
            if (e.isMouse && e.type == EventType.MouseDown && GUILayoutUtility.GetLastRect().Contains(e.mousePosition))
            {
                SetSelectedGroup(index);
            }
        }
Exemple #7
0
 public void RemoveGroup(ref TodoGroup group)
 {
     _groups.Remove(group);
 }
Exemple #8
0
 public void AddGroup(ref TodoGroup group)
 {
     _groups.Add(group);
 }