Esempio n. 1
0
    private void DrawEventList()
    {
        if (this.eventManager._eventList.Count == 0)
        {
            this.eventManager._eventList.Add("_UnSet_");
        }
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        bool flag = GUILayout.Button("Add", new GUILayoutOption[0]);

        GUILayout.Label("Event:", new GUILayoutOption[0]);
        this._eventName = EditorGUILayout.TextField("", this._eventName, new GUILayoutOption[]
        {
            GUILayout.MinWidth(280f),
            GUILayout.MaxWidth(280f)
        });
        GUILayout.EndHorizontal();
        if (flag && !EventManagerExEditor.IsNullOrWhiteSpace(this._eventName))
        {
            AddEvent(this._eventName);
            this._eventName = "";
        }
        EditorGUILayout.Space();
        List <string> list = new List <string>();

        for (int i = 1; i < this.eventManager._eventList.Count; i++)
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            bool flag2 = GUILayout.Button("Del", new GUILayoutOption[0]);
            if (flag2)
            {
                list.Add(this.eventManager._eventList[i]);
            }
            GUILayout.Label("Event:", new GUILayoutOption[0]);
            string text = this.eventManager._eventList[i];
            text = EditorGUILayout.TextField(text, new GUILayoutOption[]
            {
                GUILayout.MinWidth(280f),
                GUILayout.MaxWidth(280f)
            });
            if (text != this.eventManager._eventList[i])
            {
                EventManagerExEditor.RenameEvent(this.eventManager._eventList[i], text);
                this.eventManager._eventList[i] = text;
            }
            GUILayout.EndHorizontal();
        }
        for (int j = 0; j < list.Count; j++)
        {
            string text2 = list[j];
            this.eventManager._eventList.Remove(text2);
            EventManagerExEditor.RenameEvent(text2, "");
        }
    }
Esempio n. 2
0
 private void DrawEventListMenu()
 {
     this.eventManager._eventMenuListFoldout = EditorGUILayout.Foldout(this.eventManager._eventMenuListFoldout, "Event Menu List");
     if (this.eventManager._eventMenuListFoldout)
     {
         GUILayout.BeginVertical("Box", new GUILayoutOption[0]);
         if (this.eventManager._eventList.Count == 0)
         {
             this.eventManager._eventList.Add("_UnSet_");
         }
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         bool flag = GUILayout.Button("Add", new GUILayoutOption[0]);
         GUILayout.Label("Event:", new GUILayoutOption[0]);
         this._eventName = EditorGUILayout.TextField("", this._eventName, new GUILayoutOption[]
         {
             GUILayout.MinWidth(280f),
             GUILayout.MaxWidth(280f)
         });
         GUILayout.EndHorizontal();
         if (flag && !EventManagerExEditor.IsNullOrWhiteSpace(this._eventName))
         {
             AddEvent(this._eventName);
             this._eventName = "";
         }
         EditorGUILayout.Space();
         string[] array = this.eventManager._eventList.ToArray();
         this.menuListIndex = EditorGUILayout.Popup(this.menuListIndex, array, new GUILayoutOption[0]);
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         bool flag2 = GUILayout.Button("Del", new GUILayoutOption[0]);
         if (flag2 && this.menuListIndex > 0)
         {
             this.eventManager._eventList.Remove(array[this.menuListIndex]);
             EventManagerExEditor.RenameEvent(array[this.menuListIndex], "");
             array = this.eventManager._eventList.ToArray();
             this.menuListIndex--;
         }
         if (array != null && array.Length > 0)
         {
             if (this.eventManager._eventList[0] == "UnSet")
             {
                 this.eventManager._eventList[0] = "_UnSet_";
             }
             GUILayout.Label("Event:", new GUILayoutOption[0]);
             string text = array[this.menuListIndex];
             text = EditorGUILayout.TextField(text, new GUILayoutOption[]
             {
                 GUILayout.MinWidth(280f),
                 GUILayout.MaxWidth(280f)
             });
             if (text != this.eventManager._eventList[this.menuListIndex] && this.menuListIndex != 0)
             {
                 EventManagerExEditor.RenameEvent(this.eventManager._eventList[this.menuListIndex], text);
                 this.eventManager._eventList[this.menuListIndex] = text;
             }
         }
         GUILayout.EndHorizontal();
         GUILayout.Space(5f);
         GUILayout.BeginVertical("Box", new GUILayoutOption[0]);
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GameObject[] array2 = null;
         if (GUILayout.Button("Locate EventListeners", new GUILayoutOption[0]))
         {
             array2 = EventManagerExEditor.FindEventListeners(array[this.menuListIndex]);
         }
         if (GUILayout.Button("Locate EventTriggers", new GUILayoutOption[0]))
         {
             array2 = EventManagerExEditor.FindEventTriggers(array[this.menuListIndex]);
         }
         if (array2 != null && array2.Length > 0)
         {
             Selection.objects = array2;
         }
         GUILayout.EndHorizontal();
         GUILayout.EndVertical();
         GUILayout.Space(10f);
         GUILayout.BeginVertical("Box", new GUILayoutOption[0]);
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         if (GUILayout.Button("Clear Event List", new GUILayoutOption[0]) && EditorUtility.DisplayDialog("Event Manager List", "You are about to clear the entire event list, Are you sure you want to do this?!!", "Ok", "Cancel"))
         {
             this.ClearEventList();
         }
         if (GUILayout.Button("Clear All", new GUILayoutOption[0]) && EditorUtility.DisplayDialog("Event Manager List", "You are about to clear the entire event list, event listeners and event triggers, Are you sure you want to do this?!!", "Ok", "Cancel"))
         {
             this.ClearAll();
         }
         GUILayout.EndHorizontal();
         GUILayout.Space(10f);
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         if (GUILayout.Button("Load Events From File", new GUILayoutOption[0]))
         {
             string text2 = EditorUtility.OpenFilePanel("Load Event Names from txt file", "", "txt");
             if (text2 != null && text2.Length > 0)
             {
                 string[] files = Directory.GetFiles(text2);
                 for (int i = 0; i < files.Length; i++)
                 {
                     this.eventManager.AddEventNamesFromFile(files[i]);
                     this.menuListIndex = 0;
                 }
             }
         }
         if (GUILayout.Button("Save Events To File", new GUILayoutOption[0]))
         {
             string text3 = EditorUtility.SaveFilePanel("Save Event List to a txt file", "", "EventList.txt", "txt");
             if (text3 != null && text3.Length != 0)
             {
                 this.eventManager.ExportEventNamesToFile(text3);
             }
         }
         if (GUILayout.Button("Unload Events From File", new GUILayoutOption[0]))
         {
             string text4 = EditorUtility.OpenFilePanel("Unload Event Names From txt file", "", "txt");
             if (text4 != null && text4.Length > 0)
             {
                 string[] files2 = Directory.GetFiles(text4);
                 for (int j = 0; j < files2.Length; j++)
                 {
                     this.eventManager.RemoveEventNamesFromFile(files2[j]);
                     this.menuListIndex = 0;
                 }
             }
         }
         GUILayout.EndHorizontal();
         GUILayout.EndVertical();
         GUILayout.EndVertical();
     }
 }