/// <summary>
        /// display a particular task detail. case by case depending on the task type
        /// </summary>
        public void DisplayTaskDetail(Task t)
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            // task type
            GUILayout.Label(t.GetType().Name, EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("GO", GUILayout.Width(50));
            t.GameObject = (GameObject)EditorGUILayout.ObjectField(t.GameObject, typeof(GameObject), true);
            GUILayout.EndHorizontal();

            // go name
            GUILayout.BeginHorizontal();
            GUILayout.Label("GOName", GUILayout.Width(50));
            t.GOName = GUILayout.TextField(t.GOName);
            GUILayout.EndHorizontal();

            // task name
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", GUILayout.Width(50));
            t.TaskName = GUILayout.TextField(t.TaskName);
            GUILayout.EndHorizontal();

            // task delay
            GUILayout.BeginHorizontal();
            GUILayout.Label("Delay", GUILayout.Width(50));
            t.TaskDelay = EditorGUILayout.FloatField(t.TaskDelay);
            GUILayout.EndHorizontal();

            // task description
            GUILayout.BeginHorizontal();
            GUILayout.Label("Description");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            t.Description = GUILayout.TextArea(t.Description, GUILayout.Height(100));
            GUILayout.EndHorizontal();

            switch (t.GetType().Name)
            {
            case "MovingTask":
            {
                DisplayMovingTaskDetail(t);
            }
            break;
            }
            GUILayout.EndVertical();

            // for task events
            GUILayout.BeginVertical(EditorStyles.helpBox);
            for (int i = 0; i < t.TaskEvents.Count; i++)
            {
                GUILayout.BeginHorizontal();

                var tevent = t.TaskEvents[i];

                GUIStyle style = new GUIStyle(EditorStyles.toolbarButton);
                style.alignment = TextAnchor.MiddleLeft;
                bool clicked = GUILayout.Toggle(i == SelectedTaskEventId, i + 1 + ". " + tevent.GetType().Name, style);
                if (clicked != (i == SelectedTaskEventId))
                {
                    if (clicked)
                    {
                        SelectedTaskEventId = i;
                        GUI.FocusControl(null);
                    }
                    else
                    {
                        SelectedTaskEventId = -1;
                    }
                }

                // remove task from task event list
                if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)))
                {
                    if (SelectedTaskEventId != -1)
                    {
                        SelectedTaskEventId = -1;
                    }
                    t.TaskEvents.RemoveAt(i);
                }

                GUILayout.EndHorizontal();

                // display task detail if task is selected
                if (i == SelectedTaskEventId)
                {
                    switch (tevent.GetType().Name)
                    {
                    case "TransformTaskEvent":
                    {
                        DisplayTransformTaskEventIOfTask(t, i);
                    }
                    break;

                    case "AnimationTaskEvent":
                    {
                        DisplayAnimationTaskEventIOfTask(t, i);
                    }
                    break;
                    }
                }

                /*if (GUILayout.Button("Remove Task Event"))
                 * {
                 *  t.TaskEvents.Remove(tevent);
                 * }*/
            }

            if (GUILayout.Button("Add Task Event"))
            {
                GenericMenu genericMenu = new GenericMenu();
                for (int eventTypeId = 0; eventTypeId < TaskListEditorUtility.EventTypes().Length; eventTypeId++)
                {
                    genericMenu.AddItem(new GUIContent(TaskListEditorUtility.EventTypes()[eventTypeId]), false,
                                        (param) =>
                    {
                        int index = (int)param;
                        switch (index)
                        {
                        case 0:
                            {
                                t.TaskEvents.Add(new TransformTaskEvent());
                            }
                            break;

                        case 1:
                            {
                                t.TaskEvents.Add(new AnimationTaskEvent());
                            }
                            break;
                        }
                    }
                                        , eventTypeId);
                }
                genericMenu.ShowAsContext();
            }
            GUILayout.EndVertical();
        }
Beispiel #2
0
        /// <summary>
        /// display a particular task detail. case by case depending on the task type
        /// </summary>
        public void DisplayTaskDetail(Task t)
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            // task type
            GUILayout.Label(t.GetType().Name, EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("GO", GUILayout.Width(50));
            t.GameObject = (GameObject)EditorGUILayout.ObjectField(t.GameObject, typeof(GameObject), true);
            GUILayout.EndHorizontal();

            // go name
            GUILayout.BeginHorizontal();
            GUILayout.Label("GOName", GUILayout.Width(50));
            t.GOName = GUILayout.TextField(t.GOName);
            GUILayout.EndHorizontal();

            // task name
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", GUILayout.Width(50));
            t.TaskName = GUILayout.TextField(t.TaskName);
            GUILayout.EndHorizontal();

            // task description
            GUILayout.BeginHorizontal();
            GUILayout.Label("Description");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            t.Description = GUILayout.TextArea(t.Description, GUILayout.Height(100));
            GUILayout.EndHorizontal();

            switch (t.GetType().Name)
            {
            case "MovingTask":
            {
                DisplayMovingTaskDetail(t);
            }
            break;
            }
            GUILayout.EndVertical();

            // for task event
            GUILayout.BeginVertical(EditorStyles.helpBox);
            if (t.TaskEvent != null)
            {
                // task event type
                GUILayout.Label(t.TaskEvent.GetType().Name, EditorStyles.boldLabel);

                switch (t.TaskEvent.GetType().Name)
                {
                case "TransformTaskEvent":
                {
                    DisplayTransformTaskEventOfTask(t);
                } break;
                }

                if (GUILayout.Button("Remove Task Event"))
                {
                    t.TaskEvent = null;
                }
            }
            else
            {
                if (GUILayout.Button("Add Task Event"))
                {
                    GenericMenu genericMenu = new GenericMenu();
                    for (int eventTypeId = 0; eventTypeId < TaskListEditorUtility.EventTypes().Length; eventTypeId++)
                    {
                        genericMenu.AddItem(new GUIContent(TaskListEditorUtility.EventTypes()[eventTypeId]), false,
                                            (param) =>
                        {
                            int index = (int)param;
                            switch (index)
                            {
                            case 0:
                                {
                                    t.TaskEvent = new TransformTaskEvent();
                                }
                                break;
                            }
                        }
                                            , eventTypeId);
                    }
                    genericMenu.ShowAsContext();
                }
            }

            GUILayout.EndVertical();
        }