コード例 #1
0
        private static void AddPrefabMenuItems(ref GenericMenu menu, ActionUtility.ActionCreationParams actionParams)
        {
            Type        type = actionParams.parameter.GetType();
            List <Type> actionsSortedByCategory = ActionTargets.GetActionsSortedByCategory();

            using (List <Type> .Enumerator enumerator = actionsSortedByCategory.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Type current = enumerator.get_Current();
                    ActionUtility.ActionCreationParams actionCreationParams = new ActionUtility.ActionCreationParams(actionParams);
                    List <ActionTarget> actionTargets = ActionTargets.GetActionTargets(current);
                    using (List <ActionTarget> .Enumerator enumerator2 = actionTargets.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            ActionTarget current2 = enumerator2.get_Current();
                            if (current2.get_AllowPrefabs() && current2.get_ObjectType().IsAssignableFrom(type))
                            {
                                actionCreationParams.actionType   = current;
                                actionCreationParams.actionTarget = current2;
                                menu.AddItem(new GUIContent(Labels.GetActionLabel(current)), false, new GenericMenu.MenuFunction2(ActionUtility.AddAction), actionCreationParams);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private static void AddObjectMenuItems(ref GenericMenu menu, ActionUtility.ActionCreationParams actionParams, bool isSubMenu = false)
        {
            Type        type = actionParams.parameter.GetType();
            string      text = isSubMenu ? (Labels.StripNamespace(type.get_FullName()) + '/') : "";
            List <Type> actionsSortedByCategory = ActionTargets.GetActionsSortedByCategory();

            using (List <Type> .Enumerator enumerator = actionsSortedByCategory.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Type current = enumerator.get_Current();
                    ActionUtility.ActionCreationParams actionCreationParams = new ActionUtility.ActionCreationParams(actionParams);
                    List <ActionTarget> actionTargets = ActionTargets.GetActionTargets(current);
                    using (List <ActionTarget> .Enumerator enumerator2 = actionTargets.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            ActionTarget current2 = enumerator2.get_Current();
                            if (ActionUtility.PinToTopOfMenu(current) && current2.get_ObjectType().IsAssignableFrom(type))
                            {
                                actionCreationParams.actionType   = current;
                                actionCreationParams.actionTarget = current2;
                                menu.AddItem(new GUIContent(text + Labels.GetActionLabel(current)), false, new GenericMenu.MenuFunction2(ActionUtility.AddAction), actionCreationParams);
                            }
                        }
                    }
                }
            }
            if (menu.GetItemCount() > 2)
            {
                menu.AddSeparator(text);
            }
            using (List <Type> .Enumerator enumerator3 = actionsSortedByCategory.GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    Type current3 = enumerator3.get_Current();
                    ActionUtility.ActionCreationParams actionCreationParams2 = new ActionUtility.ActionCreationParams(actionParams);
                    List <ActionTarget> actionTargets2 = ActionTargets.GetActionTargets(current3);
                    using (List <ActionTarget> .Enumerator enumerator4 = actionTargets2.GetEnumerator())
                    {
                        while (enumerator4.MoveNext())
                        {
                            ActionTarget current4 = enumerator4.get_Current();
                            if (!ActionUtility.PinToTopOfMenu(current3) && current4.get_ObjectType().IsAssignableFrom(type))
                            {
                                actionCreationParams2.actionType   = current3;
                                actionCreationParams2.actionTarget = current4;
                                string actionLabel = Labels.GetActionLabel(current3);
                                string text2       = Actions.GetActionCategory(current3) + '/';
                                menu.AddItem(new GUIContent(text + text2 + actionLabel), false, new GenericMenu.MenuFunction2(ActionUtility.AddAction), actionCreationParams2);
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        public static void Edit(Type actionType)
        {
            Object asset = ActionScripts.GetAsset(actionType);

            if (asset != null)
            {
                AssetDatabase.OpenAsset(asset);
                return;
            }
            Debug.LogError(string.Format(Strings.get_Error_Missing_Script(), Labels.GetActionLabel(actionType)));
        }
コード例 #4
0
 public static string GetActionLabel(SkillStateAction action)
 {
     if (action == null)
     {
         return(Strings.get_Label_None_Action());
     }
     if (string.IsNullOrEmpty(action.get_Name()))
     {
         return(Labels.GetActionLabel(action.GetType()));
     }
     return(action.get_Name());
 }
コード例 #5
0
 private void DoSortedByFSM()
 {
     this.currentFSM    = null;
     this.currentState  = null;
     this.currentAction = null;
     using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ActionReport current = enumerator.get_Current();
             if (!(current.fsm == null) && current.state != null && current.action != null)
             {
                 if (current.fsm != this.currentFSM)
                 {
                     this.currentFSM = current.fsm;
                     SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
                     if (GUILayout.Button(Labels.GetFullFsmLabel(current.fsm.get_Fsm()), EditorStyles.get_label(), new GUILayoutOption[0]))
                     {
                         ActionReportWindow.SelectReport(current);
                         break;
                     }
                     EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
                 }
                 if (current.state != this.currentState)
                 {
                     this.currentState = current.state;
                     SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
                     if (GUILayout.Button(Strings.get_Tab() + current.state.get_Name(), EditorStyles.get_label(), new GUILayoutOption[0]))
                     {
                         ActionReportWindow.SelectReport(current);
                         break;
                     }
                     EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
                 }
                 if (current.action != this.currentAction)
                 {
                     SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
                     this.currentAction = current.action;
                     if (GUILayout.Button(Strings.get_Tab2() + Labels.GetActionLabel(current.action), EditorStyles.get_label(), new GUILayoutOption[0]))
                     {
                         ActionReportWindow.SelectReport(current);
                         break;
                     }
                     EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
                 }
                 ActionReportWindow.DoReportLine(Strings.get_Tab3(), current);
             }
         }
     }
 }
コード例 #6
0
        private void DoBottomPanel()
        {
            SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
            if (this.selectedAction != null)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label(Labels.GetActionLabel(this.selectedAction), SkillEditorStyles.ActionPreviewTitle, new GUILayoutOption[]
                {
                    GUILayout.MaxWidth(base.get_position().get_width() - 30f)
                });
                GUILayout.FlexibleSpace();
                if (SkillEditorGUILayout.HelpButton("Online Help"))
                {
                    EditorCommands.OpenWikiPage(this.previewAction);
                }
                GUILayout.EndHorizontal();
                string tooltip = Actions.GetTooltip(this.selectedAction);
                GUILayout.Box(tooltip, SkillEditorStyles.LabelWithWordWrap, new GUILayoutOption[0]);
                if (Event.get_current().get_type() == 7)
                {
                    this.descriptionHeight = GUILayoutUtility.GetLastRect().get_height();
                }
                ActionEditor.PreviewMode = true;
                EditorGUILayout.Space();
                SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
                if (FsmEditorSettings.ShowActionPreview)
                {
                    this.DoSelectedActionPreview();
                }
                ActionEditor.PreviewMode = false;
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            bool flag = GUILayout.Toggle(FsmEditorSettings.ShowActionPreview, Strings.get_ActionSelector_Preview(), new GUILayoutOption[0]);

            if (flag != FsmEditorSettings.ShowActionPreview)
            {
                FsmEditorSettings.ShowActionPreview = flag;
                FsmEditorSettings.SaveSettings();
            }
            EditorGUI.BeginDisabledGroup(SkillEditor.SelectedState == null || this.selectedAction == null || FsmGraphView.EditingDisable);
            if (GUILayout.Button(new GUIContent(Strings.get_ActionSelector_Add_Action_To_State(), Strings.get_ActionSelector_Add_Action_To_State_Tooltip()), new GUILayoutOption[0]))
            {
                this.AddSelectedActionToState();
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
コード例 #7
0
        private static bool ActionNameMatchesFilter(Type actionType, IEnumerable <string> filter)
        {
            string text = Labels.GetActionLabel(actionType).ToUpper().Replace(" ", "");

            using (IEnumerator <string> enumerator = filter.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.get_Current();
                    if (!text.Contains(current))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #8
0
        public static void Init()
        {
            ActionScripts.actionScriptLookup.Clear();
            List <Type> list = new List <Type>(Actions.List);

            MonoScript[] array  = (MonoScript[])Resources.FindObjectsOfTypeAll(typeof(MonoScript));
            MonoScript[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                MonoScript monoScript = array2[i];
                string     text       = Labels.NicifyVariableName(monoScript.get_name());
                Type       type       = null;
                using (List <Type> .Enumerator enumerator = list.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Type current = enumerator.get_Current();
                        if (text == Labels.GetActionLabel(current))
                        {
                            if (!ActionScripts.actionScriptLookup.ContainsKey(current))
                            {
                                ActionScripts.actionScriptLookup.Add(current, monoScript);
                            }
                            type = current;
                        }
                    }
                }
                if (type != null)
                {
                    list.Remove(type);
                    if (list.get_Count() == 0)
                    {
                        return;
                    }
                }
            }
        }
コード例 #9
0
        private void DoLogLine(SkillLogEntry entry, int index)
        {
            if (!this.EntryIsVisible(entry))
            {
                return;
            }
            if (entry.get_LogType() == 6)
            {
                this.currentState = entry.get_State();
                SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
            }
            if (this.selectedEntry != null && index > this.selectedEntryIndex)
            {
                GUI.set_color(new Color(1f, 1f, 1f, 0.3f));
            }
            if (entry.get_LogType() == 9 || entry.get_LogType() == 10)
            {
                GUI.set_backgroundColor(SkillEditorStyles.DefaultBackgroundColor);
            }
            else
            {
                GUI.set_backgroundColor((this.currentState != null) ? PlayMakerPrefs.get_Colors()[this.currentState.get_ColorIndex()] : Color.get_grey());
            }
            GUILayout.BeginVertical(SkillEditorStyles.LogBackground, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            Color backgroundColor = GUI.get_backgroundColor();

            GUI.set_backgroundColor(Color.get_white());
            GUIStyle gUIStyle = SkillEditorStyles.GetLogTypeStyles()[entry.get_LogType()];

            GUILayout.Label("", gUIStyle, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(20f)
            });
            GUI.set_backgroundColor(backgroundColor);
            gUIStyle = SkillEditorStyles.LogLine;
            if (GUILayout.Button(FsmEditorSettings.LogShowTimecode ? entry.get_TextWithTimecode() : entry.get_Text(), gUIStyle, new GUILayoutOption[0]))
            {
                this.SelectLogEntry(entry);
            }
            GUILayout.EndHorizontal();
            if (this.ShowSentBy(entry))
            {
                if (string.IsNullOrEmpty(entry.get_Text2()))
                {
                    entry.set_Text2(Strings.get_FsmLog_Label_Sent_By() + Labels.GetFullStateLabel(entry.get_SentByState()));
                    if (entry.get_Action() != null)
                    {
                        entry.set_Text2(entry.get_Text2() + " : " + Labels.GetActionLabel(entry.get_Action()));
                    }
                }
                if (GUILayout.Button(entry.get_Text2(), SkillEditorStyles.LogLine2, new GUILayoutOption[0]))
                {
                    SkillLogger.OnClickSentBy(entry);
                }
                EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
            }
            else
            {
                if (this.ShowEventTarget(entry))
                {
                    if (string.IsNullOrEmpty(entry.get_Text2()))
                    {
                        entry.set_Text2(Strings.get_FsmLog_Label_Target() + SkillLogger.GetEventTargetLabel(entry));
                    }
                    if (GUILayout.Button(entry.get_Text2(), SkillEditorStyles.LogLine2, new GUILayoutOption[0]))
                    {
                        this.OnClickEventTarget(entry);
                        GUIUtility.ExitGUI();
                        return;
                    }
                    EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
                }
                else
                {
                    if (this.ShowHitGameObject(entry))
                    {
                        if (string.IsNullOrEmpty(entry.get_Text2()))
                        {
                            entry.set_Text2("WITH: " + entry.get_GameObjectName());
                            entry.set_GameObjectIcon(EditorHacks.GetIconForObject(entry.get_GameObject()));
                        }
                        if (entry.get_GameObject() != null)
                        {
                            if (GUILayout.Button(entry.get_Text2(), SkillEditorStyles.LogLine2, new GUILayoutOption[0]))
                            {
                                Selection.set_activeGameObject(entry.get_GameObject());
                                GUIUtility.ExitGUI();
                                return;
                            }
                            Rect lastRect = GUILayoutUtility.GetLastRect();
                            EditorGUIUtility.AddCursorRect(lastRect, 4);
                            if (entry.get_GameObjectIcon() != null)
                            {
                                lastRect.Set(lastRect.get_xMin(), lastRect.get_yMin() + 2f, 27f, lastRect.get_height() - 2f);
                                GUI.Label(lastRect, entry.get_GameObjectIcon());
                            }
                        }
                        else
                        {
                            GUILayout.Label(entry.get_Text2() + " (Destroyed)", SkillEditorStyles.LogLine2, new GUILayoutOption[0]);
                        }
                    }
                }
            }
            GUILayout.EndVertical();
            if (entry == this.selectedEntry)
            {
                this.beforeSelected = this.prevEntry;
                GUI.set_backgroundColor(Color.get_white());
                GUILayout.Box(GUIContent.none, SkillEditorStyles.LogLineTimeline, new GUILayoutOption[0]);
            }
            if (this.prevEntry == this.selectedEntry)
            {
                this.afterSelected = entry;
            }
            this.prevEntry = entry;
            this.numEntriesDrawn++;
        }
コード例 #10
0
        private void DoActionButton(string category, Type actionType)
        {
            string   actionLabel = Labels.GetActionLabel(actionType);
            bool     flag        = actionType == this.selectedAction && category == this.selectedActionCategory;
            GUIStyle gUIStyle    = flag ? SkillEditorStyles.ActionItemSelected : SkillEditorStyles.ActionItem;
            GUIStyle gUIStyle2   = flag ? SkillEditorStyles.ActionLabelSelected : SkillEditorStyles.ActionLabel;

            GUILayout.BeginHorizontal(gUIStyle, new GUILayoutOption[0]);
            int    usageCount = Actions.GetUsageCount(actionType);
            string text       = (usageCount > 0) ? string.Format(Strings.get_ActionSelector_Count_Postfix(), usageCount) : "";
            float  num        = base.get_position().get_width() - 42f;

            if (usageCount > 0)
            {
                num -= gUIStyle2.CalcSize(new GUIContent(text)).x + 3f;
            }
            GUILayout.Label(actionLabel, gUIStyle2, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(num)
            });
            if (usageCount > 0)
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(text, gUIStyle2, new GUILayoutOption[0]);
            }
            GUILayout.EndHorizontal();
            Rect lastRect = GUILayoutUtility.GetLastRect();

            if (this.mousePos.y > this.scrollPosition.y && this.mousePos.y < this.scrollPosition.y + this.scrollViewHeight && lastRect.Contains(this.mousePos))
            {
                this.mouseOverAction = actionType;
            }
            if (this.mouseOverAction == actionType)
            {
                if (this.eventType == null)
                {
                    this.SelectAction(actionType, category);
                    if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey())
                    {
                        this.GenerateActionContextMenu().ShowAsContext();
                    }
                    if (Event.get_current().get_clickCount() > 1 && !FsmGraphView.EditingDisable)
                    {
                        this.AddSelectedActionToState();
                        this.addingAction = true;
                    }
                    GUIUtility.ExitGUI();
                    return;
                }
                if (!this.addingAction && this.eventType == 3)
                {
                    this.DragAction(actionType, category);
                    GUIUtility.ExitGUI();
                    return;
                }
                if (this.eventType == 1)
                {
                    DragAndDropManager.Reset();
                    this.addingAction = false;
                }
            }
            if (flag)
            {
                this.beforeSelected         = this.prevAction;
                this.beforeSelectedCategory = this.prevActionCategory;
                if (Event.get_current().get_type() == 7)
                {
                    this.selectedRect = GUILayoutUtility.GetLastRect();
                    this.selectedRect.set_y(this.selectedRect.get_y() - (this.scrollPosition.y + 20f));
                    this.selectedRect.set_height(this.selectedRect.get_height() + 20f);
                }
            }
            if (this.prevActionWasSelected)
            {
                this.afterSelected         = actionType;
                this.afterSelectedCategory = category;
            }
            this.prevAction            = actionType;
            this.prevActionCategory    = category;
            this.prevActionWasSelected = flag;
        }
コード例 #11
0
 public static string GetActionLabel(SkillStateAction action)
 {
     return(Labels.GetActionLabel(action));
 }
コード例 #12
0
 public static string GetActionLabel(Type actionType)
 {
     return(Labels.GetActionLabel(actionType));
 }
コード例 #13
0
        private static void CheckActionForErrors(SkillState state, SkillStateAction action)
        {
            if (action == null)
            {
                FsmErrorChecker.AddError(new FsmError(state, null, Strings.get_FsmErrorChecker_MissingActionError()));
                return;
            }
            action.Init(state);
            FsmErrorChecker.fsmEventTargetContext = null;
            string actionLabel = Labels.GetActionLabel(action);

            if (FsmEditorSettings.CheckForMissingActions && action is MissingAction)
            {
                FsmErrorChecker.AddError(new FsmError(state, action, Strings.get_FsmErrorChecker_StateHasMissingActionError()));
                return;
            }
            if (FsmEditorSettings.CheckForObsoleteActions)
            {
                string obsoleteMessage = CustomAttributeHelpers.GetObsoleteMessage(action.GetType());
                if (!string.IsNullOrEmpty(obsoleteMessage))
                {
                    FsmErrorChecker.AddError(new FsmError(state, action, obsoleteMessage));
                }
            }
            Type type = action.GetType();

            FieldInfo[] fields = ActionData.GetFields(type);
            FieldInfo[] array  = fields;
            for (int i = 0; i < array.Length; i++)
            {
                FieldInfo fieldInfo = array[i];
                Type      fieldType = fieldInfo.get_FieldType();
                object    value     = fieldInfo.GetValue(action);
                if (fieldType == typeof(SkillEventTarget))
                {
                    SkillEventTarget fsmEventTarget = (SkillEventTarget)value;
                    if (actionLabel == "Set Event Target")
                    {
                        FsmErrorChecker.fsmEventTargetContextGlobal = fsmEventTarget;
                    }
                    else
                    {
                        FsmErrorChecker.fsmEventTargetContext = fsmEventTarget;
                    }
                }
                FsmErrorChecker.CheckActionParameter(state, action, fieldInfo);
            }
            string text = "";

            try
            {
                text = action.ErrorCheck();
            }
            catch (Exception ex)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Bad ErrorCheck: ",
                    type,
                    "\n",
                    ex
                }));
            }
            if (!string.IsNullOrEmpty(text))
            {
                FsmErrorChecker.AddError(new FsmError(state, action, text));
            }
        }
コード例 #14
0
        private void DoSortedByAction()
        {
            List <Type> list = new List <Type>();

            using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ActionReport current = enumerator.get_Current();
                    Type         type    = current.action.GetType();
                    if (!list.Contains(type))
                    {
                        list.Add(type);
                    }
                }
            }
            this.currentAction = null;
            using (List <Type> .Enumerator enumerator2 = list.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    Type current2 = enumerator2.get_Current();
                    SkillEditorGUILayout.Divider(new GUILayoutOption[0]);
                    GUILayout.Label(Labels.GetActionLabel(current2), EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
                    this.currentFSM   = null;
                    this.currentState = null;
                    List <SkillState>   list2 = new List <SkillState>();
                    List <ActionReport> list3 = new List <ActionReport>();
                    List <string>       list4 = new List <string>();
                    SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
                    GUILayout.Label(Strings.get_ActionReportWindow_Action_Changes_Title(), EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
                    using (List <ActionReport> .Enumerator enumerator3 = ActionReport.ActionReportList.GetEnumerator())
                    {
                        while (enumerator3.MoveNext())
                        {
                            ActionReport current3 = enumerator3.get_Current();
                            Type         type2    = current3.action.GetType();
                            if (type2 == current2)
                            {
                                if (!list2.Contains(current3.state))
                                {
                                    list3.Add(current3);
                                    list2.Add(current3.state);
                                }
                                if (!list4.Contains(current3.logText))
                                {
                                    ActionReportWindow.DoReportLine(Strings.get_Tab(), current3);
                                    list4.Add(current3.logText);
                                }
                            }
                        }
                    }
                    SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
                    GUILayout.Label(Strings.get_ActionReportWindow_Effected_States_Title(), EditorStyles.get_boldLabel(), new GUILayoutOption[0]);
                    using (List <ActionReport> .Enumerator enumerator4 = list3.GetEnumerator())
                    {
                        while (enumerator4.MoveNext())
                        {
                            ActionReport current4 = enumerator4.get_Current();
                            if (current4.state != null && !(current4.fsm == null))
                            {
                                if (GUILayout.Button(Strings.get_Tab() + Labels.GetFullStateLabel(current4.state), EditorStyles.get_label(), new GUILayoutOption[0]))
                                {
                                    ActionReportWindow.SelectReport(current4);
                                    return;
                                }
                                EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4);
                            }
                        }
                    }
                }
            }
        }