private static void CheckStringParameter(string text) { if (FsmEditorSettings.CheckForRequiredField && string.IsNullOrEmpty(text) && FsmErrorChecker.IsRequiredField()) { FsmErrorChecker.AddRequiredFieldError(); } }
private static void CheckTransitionsForErrors(SkillState state) { List <string> list = new List <string>(); SkillTransition[] transitions = state.get_Transitions(); for (int i = 0; i < transitions.Length; i++) { SkillTransition fsmTransition = transitions[i]; if (FsmEditorSettings.CheckForTransitionMissingEvent && string.IsNullOrEmpty(fsmTransition.get_EventName())) { FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingEventError()); } if (FsmEditorSettings.CheckForDuplicateTransitionEvent && list.Contains(fsmTransition.get_EventName())) { FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_DuplicateTransitionEventError()); } if (!string.IsNullOrEmpty(fsmTransition.get_EventName())) { list.Add(fsmTransition.get_EventName()); } if (FsmEditorSettings.CheckForTransitionMissingTarget && string.IsNullOrEmpty(fsmTransition.get_ToState())) { FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingTargetError()); } if (state.get_Fsm() != null) { SkillEvent fsmEvent = fsmTransition.get_FsmEvent(); if (fsmEvent != null && fsmEvent.get_IsSystemEvent()) { FsmErrorChecker.CheckSystemEventsForErrors(state, fsmTransition, fsmEvent); } } } }
private static void CheckSystemEventsForErrors(SkillState state, SkillTransition transition, SkillEvent fsmEvent) { GameObject gameObject = state.get_Fsm().get_GameObject(); if (gameObject == null) { return; } if (FsmEditorSettings.CheckForMouseEventErrors && fsmEvent.get_Name().Contains("MOUSE") && gameObject.GetComponent <Collider>() == null && gameObject.GetComponent <GUIElement>() == null) { FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_MouseEventsNeedCollider()); } if ((FsmEditorSettings.CheckForCollisionEventErrors && fsmEvent.get_Name().Contains("COLLISION")) || fsmEvent.get_Name().Contains("TRIGGER")) { if (fsmEvent.get_Name().Contains("2D")) { if (gameObject.GetComponent <Collider2D>() == null && gameObject.GetComponent <Rigidbody2D>() == null) { FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_CollisionEventsNeedCollider2D()); } } else { if (gameObject.GetComponent <Collider>() == null && gameObject.GetComponent <Rigidbody>() == null) { FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_CollisionEventsNeedCollider()); } } } if (FsmEditorSettings.CheckForCollisionEventErrors && fsmEvent.get_Name().Contains("CONTROLLER COLLIDER") && gameObject.GetComponent <CharacterController>() == null) { FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_ControllerCollisionEventsNeedController()); } }
private static void DoCheckForErrors() { FsmErrorChecker.ClearErrors(false); try { using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); FsmErrorChecker.DoCheckFsmForErrors(current); } } using (List <SkillTemplate> .Enumerator enumerator2 = Templates.List.GetEnumerator()) { while (enumerator2.MoveNext()) { SkillTemplate current2 = enumerator2.get_Current(); if (!(current2 == SkillBuilder.Clipboard)) { FsmErrorChecker.DoCheckFsmForErrors(current2.fsm); } } } } catch (Exception ex) { Debug.LogError(ex.ToString()); throw; } SkillEditor.RepaintAll(); }
private void DoErrorHierarchyGUI() { this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, new GUILayoutOption[0]); GUILayout.BeginVertical(new GUILayoutOption[0]); using (List <FsmError> .Enumerator enumerator = FsmErrorChecker.GetErrors().GetEnumerator()) { while (enumerator.MoveNext()) { FsmError current = enumerator.get_Current(); if (!this.filterByFsm || current.Fsm == SkillEditor.SelectedFsm) { GUIStyle gUIStyle = SkillEditorStyles.ActionItem; if (this.selectedError == current) { gUIStyle = SkillEditorStyles.ActionItemSelected; } SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); if (GUILayout.Button(current.ErrorString, gUIStyle, new GUILayoutOption[0]) || GUILayout.Button(current.ToString(), gUIStyle, new GUILayoutOption[0])) { this.selectedError = current; ErrorSelector.GotoError(this.selectedError); } } } } GUILayout.EndVertical(); EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4); GUILayout.EndScrollView(); }
public static void Update() { if (FsmErrorChecker.SkipErrorCheck()) { return; } if (SkillEditor.NeedRepaint) { return; } if (FsmErrorChecker.checkForErrors) { FsmErrorChecker.DoCheckForErrors(); SkillSelector.RefreshView(); } else { if (FsmErrorChecker.checkFsm != null) { FsmErrorChecker.DoCheckFsmForErrors(FsmErrorChecker.checkFsm); SkillSelector.RefreshView(); } } FsmErrorChecker.checkForErrors = false; FsmErrorChecker.checkFsm = null; }
private static void CheckFsmGameObjectParameter(SkillGameObject fsmGameObject) { if (fsmGameObject == null) { fsmGameObject = new SkillGameObject(string.Empty); } if (fsmGameObject.get_UseVariable()) { if (FsmEditorSettings.CheckForRequiredField && string.IsNullOrEmpty(fsmGameObject.get_Name()) && FsmErrorChecker.IsRequiredField()) { FsmErrorChecker.AddRequiredFieldError(); return; } FsmErrorChecker.CheckBaseGameObject(fsmGameObject.get_Value()); return; } else { if (FsmEditorSettings.CheckForRequiredField && fsmGameObject.get_Value() == null && FsmErrorChecker.IsRequiredField()) { FsmErrorChecker.AddRequiredFieldError(); return; } FsmErrorChecker.CheckBaseGameObject(fsmGameObject.get_Value()); return; } }
private static void DoDebugControls() { int num = FsmErrorChecker.CountAllErrors(); string text = Strings.get_DebugToolbar_No_errors(); if (num > 0) { text = string.Format("{0} {1}", num, (num > 1) ? Strings.get_DebugToolbar_Label_Errors() : Strings.get_DebugToolbar_Label_Error()); } SkillEditorContent.DebugToolbarErrorCount.set_text(text); if (GUILayout.Button(SkillEditorContent.DebugToolbarErrorCount, SkillEditorStyles.ErrorCount, new GUILayoutOption[0])) { SkillEditor.OpenErrorWindow(); GUIUtility.ExitGUI(); } if (Event.get_current().get_type() == 7) { Rect lastRect = GUILayoutUtility.GetLastRect(); lastRect.set_x(lastRect.get_x() + 4f); lastRect.set_y(lastRect.get_y() + 2f); float width; lastRect.set_height(width = 14f); lastRect.set_width(width); GUIHelpers.DrawTexture(lastRect, (num > 0) ? SkillEditorStyles.Errors : SkillEditorStyles.NoErrors, Color.get_white(), 0); } GUILayout.Space(10f); if (GUILayout.Button(SkillEditorContent.DebugToolbarDebug, EditorStyles.get_toolbarDropDown(), new GUILayoutOption[0])) { DebugToolbar.DoDebugMenu(); } }
private static void CheckFsmStringParameter(SkillString fsmString) { if (fsmString != null && !fsmString.get_UseVariable()) { FsmErrorChecker.CheckStringParameter(fsmString.get_Value()); } }
private static FsmError AddRequiredFieldError() { FsmError fsmError = FsmErrorChecker.AddError(FsmErrorChecker.checkingState, FsmErrorChecker.checkingAction, FsmErrorChecker.checkingParameter, Strings.get_FsmErrorChecker_RequiredFieldError()); fsmError.Type = FsmError.ErrorType.requiredField; return(fsmError); }
private static void DoBottomPanel() { SkillEditorGUILayout.Divider(new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label(string.Format(Strings.get_ErrorSelector_Setup_Errors(), FsmErrorChecker.CountSetupErrors()), new GUILayoutOption[0]); GUILayout.Space(20f); GUILayout.Label(string.Format(Strings.get_ErrorSelector_Runtime_Errors(), FsmErrorChecker.CountRuntimeErrors()), new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format(Strings.get_ErrorSelector_Total_Errors(), FsmErrorChecker.CountAllErrors()), new GUILayoutOption[0]); GUILayout.EndHorizontal(); }
private static void CheckGameObjectParameter(GameObject go) { if (go == null) { if (FsmEditorSettings.CheckForRequiredField && FsmErrorChecker.IsRequiredField()) { FsmErrorChecker.AddRequiredFieldError(); } return; } FsmErrorChecker.CheckBaseGameObject(go); }
private static void CheckFsmEventParameter(SkillEvent fsmEvent) { if (FsmEditorSettings.CheckForRequiredField && fsmEvent == null && FsmErrorChecker.IsRequiredField()) { FsmErrorChecker.AddRequiredFieldError(); return; } if (FsmEditorSettings.CheckForEventNotUsed) { FsmErrorChecker.CheckForEventErrors(fsmEvent); } }
public static void CheckFsmForErrors(Skill fsm, bool immediate = false) { if (fsm != null) { if (immediate) { FsmErrorChecker.DoCheckFsmForErrors(fsm); return; } FsmErrorChecker.checkFsm = fsm; } }
public static FsmError AddRuntimeError(string error) { FsmError error2 = new FsmError { Fsm = SkillExecutionStack.get_ExecutingFsm(), State = SkillExecutionStack.get_ExecutingState(), Action = SkillExecutionStack.get_ExecutingAction(), ErrorString = error, RuntimeError = true }; return(FsmErrorChecker.AddError(error2)); }
private static void CheckOwnerDefaultParameter(SkillOwnerDefault ownerDefault) { if (ownerDefault == null) { ownerDefault = new SkillOwnerDefault(); } if (ownerDefault.get_OwnerOption() == null) { FsmErrorChecker.CheckBaseGameObject(FsmErrorChecker.gameObject); return; } FsmErrorChecker.CheckFsmGameObjectParameter(ownerDefault.get_GameObject()); }
private static void DoBreak() { if (Skill.get_IsErrorBreak()) { FsmErrorChecker.AddRuntimeError(Skill.get_LastError()); } if (FsmEditorSettings.JumpToBreakpoint && SkillEditor.Instance != null) { SkillEditor.GotoBreakpoint(); } Skill.set_HitBreakpoint(false); EditorApplication.set_isPaused(true); }
private static void CheckActionReportForErrors() { using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator()) { while (enumerator.MoveNext()) { ActionReport current = enumerator.get_Current(); if (current.isError && current.actionIndex < current.state.get_Actions().Length) { FsmErrorChecker.AddError(current.state, current.state.get_Actions()[current.actionIndex], current.parameter, current.logText); } } } }
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; } }
private static void CheckBaseGameObject(GameObject go) { if (go == null) { return; } if (FsmEditorSettings.CheckForRequiredComponent) { FsmErrorChecker.CheckForRequiredComponents(go); } if (FsmEditorSettings.CheckForPrefabRestrictions) { FsmErrorChecker.CheckPrefabRestrictions(go); } }
private static void CheckPrefabRestrictions(GameObject go) { if (go == null) { return; } if (FsmErrorChecker.ownerIsAsset) { PrefabType prefabType = PrefabUtility.GetPrefabType(go); if (prefabType != 1 && prefabType != 2) { FsmErrorChecker.AddParameterError(Strings.get_FsmErrorChecker_PrefabReferencingSceneObjectError()); } } }
private static void CheckForEventErrors(SkillEvent fsmEvent) { if (SkillEvent.IsNullOrEmpty(fsmEvent)) { return; } SkillEventTarget fsmEventTarget = FsmErrorChecker.fsmEventTargetContextGlobal; if (FsmErrorChecker.fsmEventTargetContext != null) { fsmEventTarget = FsmErrorChecker.fsmEventTargetContext; } if (fsmEventTarget == null) { fsmEventTarget = new SkillEventTarget(); } Skill fsmTarget = Events.GetFsmTarget(FsmErrorChecker.checkingFsm, fsmEventTarget); switch (fsmEventTarget.target) { case 0: if (FsmErrorChecker.checkingState != null && !Events.FsmStateRespondsToEvent(FsmErrorChecker.checkingState, fsmEvent)) { FsmError fsmError = FsmErrorChecker.AddParameterError(Strings.get_FsmErrorChecker_InvalidEventError()); fsmError.Type = FsmError.ErrorType.missingTransitionEvent; fsmError.info = fsmEvent.get_Name(); } break; case 1: case 2: break; case 3: if (fsmTarget != null && !Events.FsmRespondsToEvent(fsmTarget, fsmEvent)) { FsmErrorChecker.AddParameterError(Strings.get_FsmErrorChecker_TargetFsmMissingEventError()); } return; case 4: FsmErrorChecker.CheckGlobalEvent(fsmEvent); return; default: return; } }
private void RefreshList() { this.fsmList.Clear(); if (this.filterMode == TimelineWindow.FsmFilter.RecentlySelected) { this.fsmList.AddRange(SkillEditor.SelectionHistory.GetRecentlySelectedFSMs()); } else { using (List <Skill> .Enumerator enumerator = SkillEditor.SortedFsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); switch (this.filterMode) { case TimelineWindow.FsmFilter.All: this.fsmList.Add(current); break; case TimelineWindow.FsmFilter.OnSelectedObject: if (current.get_GameObject() != null && Selection.Contains(current.get_GameObject())) { this.fsmList.Add(current); } break; case TimelineWindow.FsmFilter.WithErrors: if (FsmErrorChecker.FsmHasErrors(current)) { this.fsmList.Add(current); } break; case TimelineWindow.FsmFilter.InScene: if (!SkillPrefabs.IsPersistent(current)) { this.fsmList.Add(current); } break; } } } } base.Repaint(); }
private void DoToolbar() { EditorGUILayout.BeginHorizontal(EditorStyles.get_toolbar(), new GUILayoutOption[0]); if (GUILayout.Button(Strings.get_ErrorSelector_Refresh(), EditorStyles.get_toolbarButton(), new GUILayoutOption[0])) { FsmErrorChecker.Refresh(); } GUILayout.FlexibleSpace(); this.filterByFsm = GUILayout.Toggle(this.filterByFsm, new GUIContent(Strings.get_ErrorSelector_Filter_Selected_FSM_Only(), Strings.get_ErrorSelector_Filter_Selected_FSM()), EditorStyles.get_toolbarButton(), new GUILayoutOption[0]); GUILayout.Space(5f); if (SkillEditorGUILayout.ToolbarSettingsButton()) { ErrorSelector.GenerateSettingsMenu().ShowAsContext(); } GUILayout.Space(-5f); EditorGUILayout.EndHorizontal(); }
private void BuildFilteredList() { this.filteredList.Clear(); this.showFullPath = true; if (this.fsmFilter == SkillSelector.FsmFilter.RecentlySelected) { this.filteredList.AddRange(SkillEditor.SelectionHistory.GetRecentlySelectedFSMs()); } else { using (List <Skill> .Enumerator enumerator = SkillEditor.SortedFsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); if (current != null && !(current.get_UsedInTemplate() != null)) { switch (this.fsmFilter) { case SkillSelector.FsmFilter.All: this.filteredList.Add(current); break; case SkillSelector.FsmFilter.OnSelectedObject: if (Selection.Contains(current.get_GameObject())) { this.filteredList.Add(current); } this.showFullPath = false; break; case SkillSelector.FsmFilter.WithErrors: if (FsmErrorChecker.FsmHasErrors(current)) { this.filteredList.Add(current); } break; } } } } } base.Repaint(); }
private void DoTemplateGUI(SkillTemplate template) { if (template == null) { return; } GUIStyle gUIStyle = SkillEditorStyles.ActionItem; if (this.selectedTemplate == template) { gUIStyle = SkillEditorStyles.ActionItemSelected; } if (GUILayout.Button(template.get_name(), gUIStyle, new GUILayoutOption[0])) { if (this.selectedTemplate == template && (this.currentEvent.get_button() == 1 || EditorGUI.get_actionKey())) { this.TemplateContextMenu(); this.currentEvent.Use(); } this.SelectTemplate(template); } if (Event.get_current().get_type() == 7 && FsmErrorChecker.FsmHasErrors(template.fsm)) { Rect rect = new Rect(GUILayoutUtility.GetLastRect()); rect.set_width(14f); rect.set_height(14f); Rect rect2 = rect; GUI.DrawTexture(rect2, SkillEditorStyles.Errors); } if (template == this.selectedTemplate) { this.beforeSelected = this.prevTemplate; if (this.eventType == 7) { this.selectedRect = GUILayoutUtility.GetLastRect(); this.selectedRect.set_y(this.selectedRect.get_y() - this.scrollPosition.y); } } if (this.prevTemplate == this.selectedTemplate) { this.afterSelected = template; } this.prevTemplate = template; }
private static void DoCheckFsmForErrors(Skill fsm) { if (fsm == null || fsm.get_OwnerObject() == null) { return; } PlayMakerFSM playMakerFSM = fsm.get_Owner() as PlayMakerFSM; if (playMakerFSM != null && playMakerFSM.get_UsesTemplate()) { return; } try { fsm.InitData(); FsmErrorChecker.checkingFsm = fsm; FsmErrorChecker.ClearFsmErrors(fsm); SkillState[] states = fsm.get_States(); for (int i = 0; i < states.Length; i++) { SkillState fsmState = states[i]; fsmState.set_Fsm(fsm); FsmErrorChecker.fsmEventTargetContextGlobal = null; SkillStateAction[] actions = fsmState.get_Actions(); for (int j = 0; j < actions.Length; j++) { SkillStateAction fsmStateAction = actions[j]; if (fsmStateAction.get_Enabled()) { FsmErrorChecker.CheckActionForErrors(fsmState, fsmStateAction); } } FsmErrorChecker.CheckTransitionsForErrors(fsmState); } FsmErrorChecker.CheckActionReportForErrors(); } catch (Exception ex) { Debug.LogError(ex.ToString()); throw; } SkillEditor.RepaintAll(); }
private static void CheckForRequiredComponents(GameObject go) { if (!FsmEditorSettings.CheckForRequiredComponent || go == null) { return; } object[] array = FsmErrorChecker.attributes; for (int i = 0; i < array.Length; i++) { Attribute attribute = (Attribute)array[i]; CheckForComponentAttribute checkForComponentAttribute = attribute as CheckForComponentAttribute; if (checkForComponentAttribute != null) { FsmErrorChecker.CheckGameObjectHasComponent(go, checkForComponentAttribute.get_Type0()); FsmErrorChecker.CheckGameObjectHasComponent(go, checkForComponentAttribute.get_Type1()); FsmErrorChecker.CheckGameObjectHasComponent(go, checkForComponentAttribute.get_Type2()); } } }
private static void CheckActionParameter(SkillState state, SkillStateAction action, FieldInfo field) { if (state == null || action == null || field == null || state.get_Fsm() == null) { return; } Object ownerObject = state.get_Fsm().get_OwnerObject(); FsmErrorChecker.ownerIsAsset = SkillPrefabs.IsPersistent(ownerObject); FsmErrorChecker.gameObject = state.get_Fsm().get_GameObject(); FsmErrorChecker.checkingFsm = state.get_Fsm(); FsmErrorChecker.checkingState = state; FsmErrorChecker.checkingAction = action; FsmErrorChecker.checkingParameter = field.get_Name(); Type fieldType = field.get_FieldType(); object value = field.GetValue(action); FsmErrorChecker.attributes = CustomAttributeHelpers.GetCustomAttributes(field); FsmErrorChecker.CheckParameterType(fieldType, value); }
private static void DoStateRow(SkillState state) { GUIContent gUIContent = new GUIContent(state.get_Name(), state.get_Name()); if (SkillEditorGUILayout.TableRow(new GUIContent[] { gUIContent }, new float[] { 1f }, SkillEditor.SelectedState == state, FsmErrorChecker.StateHasErrors(state), new GUILayoutOption[0]) >= 0) { StateSelector.SelectState(state); GUIUtility.ExitGUI(); } if (state == SkillEditor.SelectedState && Event.get_current().get_type() == 7) { StateSelector.selectedRect = GUILayoutUtility.GetLastRect(); StateSelector.selectedRect.set_y(StateSelector.selectedRect.get_y() - StateSelector.scrollPosition.y); } }