Beispiel #1
0
        private GenericMenu GenerateUsageContextMenu(SkillEvent fsmEvent)
        {
            this.UpdateUseCount();
            GenericMenu genericMenu = new GenericMenu();
            int         num;

            this.usageCount.TryGetValue(fsmEvent, ref num);
            if (num == 0)
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_No_FSMs_Use_This_Event()));
                genericMenu.AddSeparator("");
                if (SkillEditor.SelectedFsm == null || SkillEditor.SelectedFsm.HasEvent(this.selectedEvent.get_Name()))
                {
                    genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()), false, new GenericMenu.MenuFunction(this.AddSelectedEventToState));
                }
                return(genericMenu);
            }
            List <string> list = new List <string>();

            using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill current = enumerator.get_Current();
                    if (current != null && current.get_OwnerObject() != null)
                    {
                        SkillEvent[] events = current.get_Events();
                        for (int i = 0; i < events.Length; i++)
                        {
                            SkillEvent fsmEvent2 = events[i];
                            if (fsmEvent2.get_Name() == fsmEvent.get_Name())
                            {
                                string text = Labels.GenerateUniqueLabel(list, Labels.GetFullFsmLabel(current));
                                genericMenu.AddItem(new GUIContent(text), SkillEditor.SelectedFsm == current, new GenericMenu.MenuFunction2(EditorCommands.SelectFsm), current);
                                list.Add(text);
                            }
                        }
                    }
                }
            }
            genericMenu.AddSeparator("");
            if (SkillEditor.SelectedFsm == null || SkillEditor.SelectedFsm.HasEvent(this.selectedEvent.get_Name()))
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()));
            }
            else
            {
                genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_Event_to_FSM()), false, new GenericMenu.MenuFunction(this.AddSelectedEventToState));
            }
            return(genericMenu);
        }
        public static GenericMenu GenerateFsmGameObjectSelectionMenu(bool hasAddFsmOption)
        {
            SkillEditor.RebuildFsmList();
            List <GameObject> list          = new List <GameObject>();
            List <Skill>      sortedFsmList = SkillEditor.SortedFsmList;

            using (List <Skill> .Enumerator enumerator = sortedFsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill current = enumerator.get_Current();
                    if (!list.Contains(current.get_GameObject()))
                    {
                        list.Add(current.get_GameObject());
                    }
                }
            }
            GenericMenu   genericMenu = new GenericMenu();
            List <string> list2       = new List <string>();

            using (List <GameObject> .Enumerator enumerator2 = list.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    GameObject current2 = enumerator2.get_Current();
                    if (!(current2 == null))
                    {
                        string text = Labels.GenerateUniqueLabel(list2, current2.get_name());
                        if (FsmEditorSettings.AddPrefabLabel && PrefabUtility.GetPrefabType(current2) == 1)
                        {
                            text += Strings.get_Label_Prefab_postfix();
                        }
                        list2.Add(text);
                        genericMenu.AddItem(new GUIContent(text), SkillEditor.Selection.ActiveFsmGameObject == current2, new GenericMenu.MenuFunction2(SkillEditorGUILayout.SelectGameObject), current2);
                    }
                }
            }
            if (hasAddFsmOption)
            {
                genericMenu.AddSeparator(string.Empty);
                if (Selection.get_activeGameObject() != null)
                {
                    string text2 = string.Format(Strings.get_Menu_Add_FSM_to__(), Selection.get_activeGameObject().get_name());
                    genericMenu.AddItem(new GUIContent(text2), false, new GenericMenu.MenuFunction(SkillEditor.AddFsm));
                }
                else
                {
                    genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Disabled_Add_FSM_to_selected_object()));
                }
            }
            return(genericMenu);
        }
        public static GenericMenu GenerateFsmSelectionMenu(bool includeAssets, bool hasAddFsmOption)
        {
            GenericMenu genericMenu = new GenericMenu();

            genericMenu.AddItem(new GUIContent(Strings.get_Menu_None_FSM()), false, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), null);
            List <string> list          = new List <string>();
            List <Skill>  sortedFsmList = SkillEditor.SortedFsmList;

            using (List <Skill> .Enumerator enumerator = sortedFsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill current = enumerator.get_Current();
                    if (current != null && (includeAssets || !SkillPrefabs.IsPersistent(current)))
                    {
                        string text = Labels.GenerateUniqueLabel(list, Labels.GetFullFsmLabel(current));
                        list.Add(text);
                        genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), current);
                    }
                }
            }
            if (hasAddFsmOption)
            {
                genericMenu.AddSeparator(string.Empty);
                if (Selection.get_activeGameObject() != null)
                {
                    string text2 = string.Format(Strings.get_Menu_Add_FSM_to__(), Selection.get_activeGameObject().get_name());
                    genericMenu.AddItem(new GUIContent(text2), false, new GenericMenu.MenuFunction(SkillEditor.AddFsm));
                }
                else
                {
                    genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Disabled_Add_FSM_to_selected_object()));
                }
            }
            return(genericMenu);
        }
Beispiel #4
0
 public static string GenerateUniqueLabel(List <string> labels, string label)
 {
     return(Labels.GenerateUniqueLabel(labels, label));
 }