private DialogElement CreateElement(DialogElement.Type t)
    {
        DialogElement e = new DialogElement();

        e.type = t;
        return(e);
    }
    private void OnEnable()
    {
        dialog                  = target as Dialog;
        list                    = new ReorderableList(dialog.dialogs, typeof(DialogElement), true, true, true, true);
        list.elementHeight      = EditorGUIUtility.singleLineHeight * 2 + 4;
        list.drawHeaderCallback = (Rect rect) => {
            EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), "dankilog supersystem v4.20 tm (c)");
        };

        list.onAddDropdownCallback = (Rect rect, ReorderableList rl) => {
            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("Dialog"), false, OnMenuClick, CreateElement(DialogElement.Type.Dialog));

            menu.AddItem(new GUIContent("Event"), false, OnMenuClick, CreateElement(DialogElement.Type.Event));

            menu.AddItem(new GUIContent("Look At"), false, OnMenuClick, CreateElement(DialogElement.Type.LookAt));
            menu.AddItem(new GUIContent("Play Audio"), false, OnMenuClick, CreateElement(DialogElement.Type.Sound));

            menu.ShowAsContext();
        };

        list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
            DialogElement      e = dialog.dialogs[index] as DialogElement;
            DialogElement.Type t = e.type;
            rect.y += 2;
            if (t == DialogElement.Type.Dialog)
            {
                ChangeColor(rect, dialogColor);
                EditorGUI.LabelField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), "dialog");
                rect.x     += 60;
                rect.height = EditorGUIUtility.singleLineHeight * 2;
                e.string1   = EditorGUI.TextArea(new Rect(rect.x, rect.y, rect.width - 60, rect.height),
                                                 e.string1);
            }
            else if (t == DialogElement.Type.Event)
            {
                ChangeColor(rect, eventColor);
                EditorGUI.LabelField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), "event");
                rect.x   += 60;
                e.string1 = EditorGUI.TextField(new Rect(rect.x, rect.y, rect.width - 60, EditorGUIUtility.singleLineHeight),
                                                e.string1);
            }
            else if (t == DialogElement.Type.LookAt)
            {
                ChangeColor(rect, lookColor);
                EditorGUI.LabelField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), "look at");
                rect.x      += 60;
                e.transform1 = EditorGUI.ObjectField(new Rect(rect.x, rect.y, rect.width - 60, EditorGUIUtility.singleLineHeight),
                                                     "object", e.transform1, typeof(Transform), true) as Transform;
                rect.y  += EditorGUIUtility.singleLineHeight;
                e.float1 = EditorGUI.FloatField(new Rect(rect.x, rect.y, rect.width - 60, EditorGUIUtility.singleLineHeight),
                                                "time", e.float1);
            }
            else if (t == DialogElement.Type.Sound)
            {
                ChangeColor(rect, audioColor);
                EditorGUI.LabelField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), "playSound");
                rect.x += 60;
                e.audio = EditorGUI.ObjectField(new Rect(rect.x, rect.y, rect.width - 60, EditorGUIUtility.singleLineHeight),
                                                "audio source", e.audio, typeof(AudioSource), true) as AudioSource;
            }
        };
    }