示例#1
0
        public static string GetFullFsmLabel(Skill fsm)
        {
            if (fsm == null)
            {
                return("None (FSM)");
            }
            if (fsm.get_OwnerObject() == null)
            {
                return("Missing Owner");
            }
            string text;

            if (Labels.fsmFullName.TryGetValue(fsm, ref text))
            {
                return(text);
            }
            if (fsm.get_UsedInTemplate() != null)
            {
                text = "Template: " + fsm.get_UsedInTemplate().get_name();
            }
            else
            {
                text = fsm.get_OwnerName() + " : " + Labels.GetFsmLabel(fsm);
                if (FsmEditorSettings.AddPrefabLabel && PrefabUtility.GetPrefabType(fsm.get_Owner()) == 1)
                {
                    text += " (Prefab)";
                }
            }
            Labels.fsmFullName.Add(fsm, text);
            return(text);
        }
        public static GenericMenu GenerateGameObjectFsmSelectionMenu()
        {
            List <Skill> list          = new List <Skill>();
            List <Skill> sortedFsmList = SkillEditor.SortedFsmList;

            using (List <Skill> .Enumerator enumerator = sortedFsmList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Skill current = enumerator.get_Current();
                    if (current.get_GameObject() == SkillEditor.Selection.ActiveFsmGameObject)
                    {
                        list.Add(current);
                    }
                }
            }
            GenericMenu genericMenu = new GenericMenu();

            if (list.get_Count() == 0)
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Label_None()));
            }
            else
            {
                using (List <Skill> .Enumerator enumerator2 = list.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        Skill  current2 = enumerator2.get_Current();
                        string fsmLabel = Labels.GetFsmLabel(current2);
                        genericMenu.AddItem(new GUIContent(fsmLabel), SkillEditor.SelectedFsm == current2, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), current2);
                    }
                }
            }
            genericMenu.AddSeparator(string.Empty);
            if (Selection.get_activeGameObject() != null)
            {
                string text = string.Format(Strings.get_Menu_Add_FSM_to__(), Selection.get_activeGameObject().get_name());
                genericMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction(SkillEditor.AddFsm));
            }
            else
            {
                genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Disabled_Add_FSM_to_selected_object()));
            }
            return(genericMenu);
        }
示例#3
0
        public static string GetFsmSavePath(Skill fsm)
        {
            if (fsm == null)
            {
                return("");
            }
            if (fsm.get_UsedInTemplate())
            {
                return("Template." + fsm.get_UsedInTemplate().get_name());
            }
            string text = fsm.get_OwnerName() + '.' + Labels.GetFsmLabel(fsm);

            if (SkillPrefabs.IsPrefab(fsm))
            {
                return("Prefab." + text);
            }
            string text2 = (fsm.get_GameObject() != null && fsm.get_GameObject().get_scene().get_name() != null) ? fsm.get_GameObject().get_scene().get_name().Replace(".unity", "").Replace("Assets/", "").Replace("/", ".") : "";

            return(text2 + "." + text);
        }
示例#4
0
 public static string GetFsmLabel(Skill fsm)
 {
     return(Labels.GetFsmLabel(fsm));
 }
示例#5
0
        private void DoTableRow(Skill fsm)
        {
            if (fsm == null || fsm.get_Owner() == null)
            {
                return;
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[]
            {
                GUILayout.Height(15f)
            });
            fsm.get_Owner().set_enabled(GUILayout.Toggle(fsm.get_Owner().get_enabled(), new GUIContent("", Strings.get_Label_Enabled()), SkillEditorStyles.TableRowCheckBox, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(17f)
            }));
            string     fullFsmLabel = Labels.GetFullFsmLabel(fsm);
            GUIContent gUIContent   = new GUIContent("", fullFsmLabel);

            if (FsmEditorSettings.FsmBrowserShowFullPath && this.showFullPath)
            {
                gUIContent.set_text(fullFsmLabel);
            }
            else
            {
                gUIContent.set_text(Labels.GetFsmLabel(fsm));
            }
            GUIContent gUIContent2 = new GUIContent();

            if (GameStateTracker.CurrentState == GameState.Stopped)
            {
                gUIContent2.set_text((fsm.get_Template() != null) ? fsm.get_Template().fsm.get_StartState() : fsm.get_StartState());
            }
            else
            {
                gUIContent2.set_text((fsm.get_ActiveState() == null) ? Strings.get_FsmSelector_no_active_state() : fsm.get_ActiveState().get_Name());
            }
            gUIContent2.set_tooltip(gUIContent2.get_text());
            switch (SkillEditorGUILayout.TableRow(new GUIContent[]
            {
                gUIContent,
                gUIContent2
            }, new float[]
            {
                0.6f,
                0.4f
            }, SkillEditor.SelectedFsm == fsm, FsmErrorChecker.FsmHasErrors(fsm), new GUILayoutOption[0]))
            {
            case 0:
                SkillEditor.SelectFsm(fsm);
                GUIUtility.ExitGUI();
                break;

            case 1:
                SkillEditor.SelectFsm(fsm);
                SkillEditor.SelectStateByName(gUIContent2.get_text(), true);
                GUIUtility.ExitGUI();
                break;
            }
            GUILayout.EndHorizontal();
            if (fsm == SkillEditor.SelectedFsm && Event.get_current().get_type() == 7)
            {
                SkillSelector.selectedRect = GUILayoutUtility.GetLastRect();
                SkillSelector.selectedRect.set_y(SkillSelector.selectedRect.get_y() - this.scrollPosition.y);
            }
        }