Exemplo n.º 1
0
        void OnGUI()
        {
            if (Event.current.type == EventType.ValidateCommand)
            {
                if (Event.current.commandName == "UndoRedoPerformed")
                {
                    Repaint();
                }
            }

            if (list != null)
            {
                if (EditorGUILayout.BeginFadeGroup(showGroups.faded))
                {
                    ShowToDoList();
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(showEditingGroups.faded))
                {
                    ShowGroupEditing();
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(showPreferences.faded))
                {
                    ShowPreferences();
                }
                EditorGUILayout.EndFadeGroup();
            }
            else
            {
                GUIStyle warningLabel = new GUIStyle(GUI.skin.label);
                warningLabel.alignment = TextAnchor.MiddleCenter;

                GUI.Label(new Rect(0, 0, size.x, size.y), "The To-Do List can't be found in 'Resources/Editor'.\nPressing 'Fix Now' will create a Resources folder in the 'Assets' folder.", warningLabel);

                if (GUI.Button(new Rect(size.x / 2 - 100, size.y / 2 + 20, 200, 20), "Fix Now"))
                {
                    if (!Directory.Exists(Application.dataPath + "/Resources/Editor"))
                    {
                        Directory.CreateDirectory(Application.dataPath + "/Resources/Editor");
                    }

                    ToDoListObject asset         = CreateInstance <ToDoListObject>();
                    PriorityGroup  criticalGroup = new PriorityGroup();
                    PriorityGroup  majorGroup    = new PriorityGroup();
                    PriorityGroup  minorGroup    = new PriorityGroup();
                    PriorityGroup  bugsGroup     = new PriorityGroup();
                    PriorityGroup  featuresGroup = new PriorityGroup();

                    criticalGroup.groupColor = new Color(1f, 0f, 0f);
                    criticalGroup.groupName  = "Critical Issues";
                    criticalGroup.labelStyle = FontStyle.Bold;
                    majorGroup.groupColor    = new Color(0f, 0f, 1f);
                    majorGroup.groupName     = "Major Issues";
                    minorGroup.groupColor    = new Color(1f, 0f, 1f);
                    minorGroup.groupName     = "Minor Issues";
                    bugsGroup.groupColor     = new Color(1f, 0.5f, 0f);
                    bugsGroup.groupName      = "Bugs";
                    featuresGroup.groupColor = new Color(0f, 0.5f, 0f);
                    featuresGroup.groupName  = "Features";

                    asset.priorityGroups.Add(criticalGroup);
                    asset.priorityGroups.Add(majorGroup);
                    asset.priorityGroups.Add(minorGroup);
                    asset.priorityGroups.Add(bugsGroup);
                    asset.priorityGroups.Add(featuresGroup);

                    string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/Editor/ToDoList.asset");
                    AssetDatabase.CreateAsset(asset, path);
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                    UpdateAnimBools();
                    MakeEditingList();
                }
            }
        }
Exemplo n.º 2
0
 void FindList()
 {
     list = Resources.Load("Editor/ToDoList") as ToDoListObject;
 }