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)); } }
private GenericMenu GenerateActionContextMenu() { GenericMenu genericMenu = new GenericMenu(); if (Actions.GetUsageCount(this.selectedAction) == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Find_Action())); } else { List <SkillInfo> usage = Actions.GetUsage(this.selectedAction); using (List <SkillInfo> .Enumerator enumerator = usage.GetEnumerator()) { while (enumerator.MoveNext()) { SkillInfo current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(string.Format("{0}/{1}", Strings.get_Menu_Find_Action(), Labels.GetFullStateLabel(current.state))), false, new GenericMenu.MenuFunction2(SkillInfo.SelectFsmInfo), current); } } } if (SkillEditor.SelectedFsm == null || SkillEditor.SelectedState == null) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Select_a_State_to_add_Actions())); } else { genericMenu.AddSeparator(""); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_to_Top_of_Action_List()), false, new GenericMenu.MenuFunction(this.AddSelectedActionToTop)); if (SkillEditor.StateInspector.SelectedAction == null) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Add_Before_Selected_Action())); genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Add_After_Selected_Action())); } else { genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_Before_Selected_Action()), false, new GenericMenu.MenuFunction(this.AddSelectedActionBefore)); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_After_Selected_Action()), false, new GenericMenu.MenuFunction(this.AddSelectedActionAfter)); } genericMenu.AddItem(new GUIContent(Strings.get_Menu_Add_to_End_of_Action_List()), false, new GenericMenu.MenuFunction(this.AddSelectedActionToEnd)); } genericMenu.AddSeparator(""); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Find_Script()), false, new GenericMenu.MenuFunction2(ActionScripts.PingAssetByType), this.selectedAction); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Select_Script()), false, new GenericMenu.MenuFunction2(ActionScripts.SelectAssetByType), this.selectedAction); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Edit_Script()), false, new GenericMenu.MenuFunction2(ActionScripts.EditAssetByType), this.selectedAction); genericMenu.AddSeparator(""); if (Actions.CategoryContainsAction("Favorites", this.selectedAction)) { genericMenu.AddItem(new GUIContent("Remove From Favorites"), false, new GenericMenu.MenuFunction2(ActionSelector.RemoveFromFavorites), this.selectedAction); } else { genericMenu.AddItem(new GUIContent("Add To Favorites"), false, new GenericMenu.MenuFunction2(ActionSelector.AddToFavorites), this.selectedAction); } return(genericMenu); }
private void OnClickEventTarget(SkillLogEntry entry) { switch (entry.get_EventTarget().target) { case 0: case 6: break; case 1: if (entry.get_Event() != null) { GenericMenu genericMenu = new GenericMenu(); List <Skill> fsmList = SkillInfo.GetFsmList(SkillInfo.FindTransitionsUsingEvent(entry.get_Event().get_Name())); using (List <Skill> .Enumerator enumerator = fsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(Labels.GetFullFsmLabel(current)), false, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), current); } } genericMenu.ShowAsContext(); return; } break; case 2: { GameObject ownerDefaultTarget = SkillEditor.SelectedFsm.GetOwnerDefaultTarget(entry.get_EventTarget().gameObject); Skill fsm = SkillSelection.FindFsmOnGameObject(ownerDefaultTarget, entry.get_EventTarget().fsmName.get_Value()); if (fsm != null) { SkillEditor.SelectFsm(fsm); return; } break; } case 3: if (entry.get_EventTarget().fsmComponent != null) { SkillEditor.SelectFsm(entry.get_EventTarget().fsmComponent.get_Fsm()); return; } break; case 4: if (entry.get_Event() != null) { GenericMenu genericMenu2 = new GenericMenu(); List <Skill> fsmList2 = SkillInfo.GetFsmList(SkillInfo.FindTransitionsUsingEvent(entry.get_Event().get_Name())); using (List <Skill> .Enumerator enumerator2 = fsmList2.GetEnumerator()) { while (enumerator2.MoveNext()) { Skill current2 = enumerator2.get_Current(); genericMenu2.AddItem(new GUIContent(Labels.GetFullFsmLabel(current2)), false, new GenericMenu.MenuFunction2(SkillEditor.SelectFsm), current2); } } genericMenu2.ShowAsContext(); return; } break; case 5: SkillEditor.SelectFsm(entry.get_State().get_Fsm().get_Host()); break; default: return; } }
public static string GetActionLabel(SkillStateAction action) { return(Labels.GetActionLabel(action)); }
public static int GetFsmNameIndex(Skill fsm) { return(Labels.GetFsmNameIndex(fsm)); }
public static GUIContent GetRuntimeFsmLabelToFit(Skill fsm, float width, GUIStyle style) { return(Labels.GetRuntimeFsmLabelToFit(fsm, width, style)); }
public static string GenerateUniqueFsmName(GameObject go) { return(Labels.GetUniqueFsmName(go)); }
public static string StripUnityEngineNamespace(string name) { return(Labels.StripUnityEngineNamespace(name)); }
public static string GenerateUniqueLabelWithNumber(List <string> labels, string label) { return(Labels.GenerateUniqueLabelWithNumber(labels, label)); }
public static string NicifyParameterName(string name) { return(Labels.NicifyParameterName(name)); }
public static string StripNamespace(string name) { return(Labels.StripNamespace(name)); }
public static string NicifyVariableName(string name) { return(Labels.NicifyVariableName(name)); }
public static string UpdateTooltip(SkillStateAction action) { Actions.tooltipLookup.Remove(action); string text = Actions.GetTooltip(action); text = string.Format(Strings.get_Tooltip_Action(), Labels.NicifyVariableName(Labels.StripNamespace(action.GetType().ToString())), text); Actions.tooltipLookup.Add(action, text); return(text); }
private static void CheckGameObjectHasComponent(GameObject go, Type component) { if (go == null || component == null) { return; } if (go.GetComponent(component) == null) { FsmError fsmError = FsmErrorChecker.AddParameterError(Strings.get_FsmErrorChecker_RequiresComponentError() + Labels.StripUnityEngineNamespace(component.ToString()) + " Component!"); fsmError.Type = FsmError.ErrorType.missingRequiredComponent; fsmError.GameObject = go; fsmError.ObjectType = component; } }
public static string GetFullFsmLabelWithInstanceID(Skill fsm) { return(Labels.GetFullFsmLabelWithInstanceID(fsm)); }
public static string FormatTime(float time) { return(Labels.FormatTime(time)); }
public static string GetFullFsmLabelWithInstanceID(PlayMakerFSM fsm) { return(Labels.GetFullFsmLabelWithInstanceID(fsm)); }
public static string GetStateLabel(string stateName) { return(Labels.GetStateLabel(stateName)); }
public static string GetFullStateLabel(SkillState state) { return(Labels.GetFullStateLabel(state)); }
public static GUIContent GetEventLabel(SkillTransition transition) { return(Labels.GetEventLabel(transition)); }
public static string GetActionLabel(Type actionType) { return(Labels.GetActionLabel(actionType)); }
public static string GetCurrentStateLabel(Skill fsm) { return(Labels.GetCurrentStateLabel(fsm)); }
public static string GetTypeTooltip(Type type) { return(Labels.GetTypeTooltip(type)); }
public static string GetFullFsmLabel(PlayMakerFSM fsmComponent) { return(Labels.GetFullFsmLabel(fsmComponent)); }
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; }
public static string GetFullFsmLabel(Skill fsm) { return(Labels.GetFullFsmLabel(fsm)); }
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++; }
public static string GetRuntimeFsmLabel(Skill fsm) { return(Labels.GetRuntimeFsmLabel(fsm)); }
private void DoListView() { this.listArea.Set(0f, this.toolbarHeight, this.listWidth, base.get_position().get_height() - this.toolbarHeight - this.scrollbarHeight); this.listItemArea.Set(0f, 0f, this.listWidth, 20f); if (this.autoScroll) { float num = (float)this.selectedIndex * 20f; if (num < this.scrollPosition.y) { this.scrollPosition.y = num; } else { if (num > this.scrollPosition.y + this.listArea.get_height() - 20f) { this.scrollPosition.y = (float)(this.selectedIndex + 1) * 20f - this.listArea.get_height(); } } this.autoScroll = false; } GUI.BeginGroup(this.listArea); if (this.FsmList.get_Count() == 0) { GUILayout.Label(Strings.get_Label_None(), new GUILayoutOption[0]); } this.firstVisibleItem = Mathf.FloorToInt(this.scrollPosition.y / 20f); this.firstVisibleItem = Mathf.Clamp(this.firstVisibleItem, 0, this.FsmList.get_Count()); this.lastVisibleItem = this.firstVisibleItem + Mathf.CeilToInt(this.listArea.get_height() / 20f) + 1; this.lastVisibleItem = Mathf.Clamp(this.lastVisibleItem, 0, this.FsmList.get_Count()); this.listItemArea.set_y((float)this.firstVisibleItem * 20f - this.scrollPosition.y); for (int i = this.firstVisibleItem; i < this.lastVisibleItem; i++) { Skill fsm = this.FsmList.get_Item(i); bool flag = SkillEditor.SelectedFsm == fsm; if (flag) { if (this.eventType == 7) { GUI.DrawTexture(this.listItemArea, SkillEditorStyles.SelectedBG); } if (this.selectedIndex != i) { this.autoScroll = true; } this.selectedIndex = i; } if (GUI.Button(this.listItemArea, Labels.GetRuntimeFsmLabelToFit(fsm, this.listWidth, SkillEditorStyles.TableRowText), flag ? SkillEditorStyles.TableRowTextSelected : SkillEditorStyles.TableRowText)) { this.SelectFsm(fsm); } this.listItemArea.set_y(this.listItemArea.get_y() + 20f); this.line.SetColor(SkillEditorStyles.LabelTextColor); this.line.DrawLine(0.05f, 0f, this.listItemArea.get_y() - 1f, this.listWidth, this.listItemArea.get_y() - 1f); } GUI.EndGroup(); if (this.listArea.Contains(this.currentEvent.get_mousePosition()) && this.eventType == 6) { this.scrollPosition.y = this.scrollPosition.y + this.currentEvent.get_delta().y; base.Repaint(); } this.listArea.Set(0f, base.get_position().get_height() - this.scrollbarHeight, this.listWidth, this.scrollbarHeight); GUI.Box(this.listArea, GUIContent.none, EditorStyles.get_toolbar()); if (GUI.Button(this.listArea, Strings.get_Label_Refresh(), EditorStyles.get_toolbarButton())) { this.RefreshList(); } }
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); } } } } } }