Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
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();
                        }
                    }
                }
            }
        }