//------------------------------------------------------------------------------------------------------ private void HandleSendMessage(int ourFsmIndex, PlayMakerFSM fsm, FsmState state, FsmStateAction action) { if (action.GetType() == typeof(HutongGames.PlayMaker.Actions.SendMessage)) { HutongGames.PlayMaker.Actions.SendMessage sm = (HutongGames.PlayMaker.Actions.SendMessage)(action); string funcName = sm.functionCall.FunctionName; GameObject targetGO = sm.Fsm.GetOwnerDefaultTarget(sm.gameObject); string gameObjectName = ((targetGO != null) ? targetGO.name : "UNKNOWN"); if ((FilterMethodName.Length > 0) && (funcName.Contains(FilterMethodName) == false)) { return; } if ((FilterTargetGameObjectName.Length > 0) && (gameObjectName.Contains(FilterTargetGameObjectName) == false)) { return; } results += "SendMessage " + fsm.ToString() + " State " + state.Name + " calls method " + funcName + " on GameObject " + gameObjectName + "\n"; commsList.Add(new PlaymakerCommsEntry(ourFsmIndex, fsm, state, action)); } }
//------------------------------------------------------------------------------------------------------ // Show the results //------------------------------------------------------------------------------------------------------ void ShowCommsResults(int n) { //------------------------------------------------------------------------------------------------------ // Any info we want to let the user know to help them understand why things are as shown... if ((FilterMethodName.Length > 0) || (FilterStateName.Length > 0) || (FilterFsmName.Length > 0) || (FilterEventName.Length > 0) || (FilterTargetFsmName.Length > 0) || (FilterTargetGameObjectName.Length > 0)) { GUILayout.Label("Note: CASE SENSITIVE filter(s) are in use.", EditorStyles.boldLabel); EditorGUILayout.Space(); } if ((pmCommsTool.ShowSendEvent == true) && (pmCommsTool.ShowSendMessage == true) && (pmCommsTool.ShowActivateGameObject == true)) { GUILayout.Label("FSMs with a SendMessage or SendEvent or ActivateGameObject here:", EditorStyles.boldLabel); } else { if ((pmCommsTool.ShowSendEvent == true) || (pmCommsTool.ShowSendMessage == true) || (pmCommsTool.ShowActivateGameObject == true)) { string info = "NOTE: Only FSMs with a "; if (pmCommsTool.ShowSendEvent == true) { info += "SendEvent "; } if (pmCommsTool.ShowSendMessage == true) { info += "SendMessage "; } if (pmCommsTool.ShowActivateGameObject == true) { info += "ActivateGameObject "; } info += "action are here:"; GUILayout.Label(info, EditorStyles.boldLabel); } } //------------------------------------------------------------------------------------------------------ // Show the results int currentFsmIndex = -1; for (int i = 0; i < pmCommsTool.commsList.Count; ++i) { if (pmCommsTool.commsList[i].ourFsmIndex > currentFsmIndex) { currentFsmIndex = pmCommsTool.commsList[i].ourFsmIndex; EditorGUILayout.Space(); GUILayout.Label("(FSM name)= " + pmCommsTool.commsList[i].fsm.name, EditorStyles.boldLabel); pmCommsTool.commsList[i].showMyFsm = EditorGUILayout.Toggle( "Show this FSM?", pmCommsTool.commsList[i].showMyFsm); if (pmCommsTool.commsList[i].showMyFsm == true) { GUILayout.Label("States with entry:-", EditorStyles.label); string state = ""; bool showState = true; for (int ii = i; ii < pmCommsTool.commsList.Count; ++ii) { if (pmCommsTool.commsList[ii].ourFsmIndex == currentFsmIndex) { if (state != pmCommsTool.commsList[ii].state.Name) { state = pmCommsTool.commsList[ii].state.Name; showState = pmCommsTool.commsList[ii].showMyState = EditorGUILayout.Toggle( (pmCommsTool.commsList[ii].state.Name + ":"), pmCommsTool.commsList[ii].showMyState); } if (showState == true) { if (pmCommsTool.commsList[ii].action.GetType() == typeof(HutongGames.PlayMaker.Actions.SendEvent)) { HutongGames.PlayMaker.Actions.SendEvent se = (HutongGames.PlayMaker.Actions.SendEvent)(pmCommsTool.commsList[ii].action); string TargetFsmName = se.eventTarget.fsmName.Value; if (TargetFsmName.Length == 0) { TargetFsmName = se.eventTarget.fsmName.Name; } if (TargetFsmName.Length == 0) { TargetFsmName = "UNKOWN"; } GUILayout.Label( "SentEvent:" + se.sendEvent.Name + " to (FSM called) " + TargetFsmName + " on GameObject " + se.eventTarget.gameObject.GameObject.ToString() , EditorStyles.label); } else if (pmCommsTool.commsList[ii].action.GetType() == typeof(HutongGames.PlayMaker.Actions.SendMessage)) { HutongGames.PlayMaker.Actions.SendMessage sm = (HutongGames.PlayMaker.Actions.SendMessage)(pmCommsTool.commsList[ii].action); string funcName = sm.functionCall.FunctionName; GameObject targetGO = sm.Fsm.GetOwnerDefaultTarget(sm.gameObject); string gameObjectName = ((targetGO == null) ? "UNKNOWN NAME" : targetGO.name); GUILayout.Label( "SendMessage to GameObject " + gameObjectName + " method=" + funcName , EditorStyles.label); } else if (pmCommsTool.commsList[ii].action.GetType() == typeof(HutongGames.PlayMaker.Actions.ActivateGameObject)) { HutongGames.PlayMaker.Actions.ActivateGameObject ago = (HutongGames.PlayMaker.Actions.ActivateGameObject)(pmCommsTool.commsList[ii].action); GameObject targetGameObject = ago.Fsm.GetOwnerDefaultTarget(ago.gameObject); string targetGOname = ((targetGameObject != null) ? targetGameObject.name : "UNKNOWN"); GUILayout.Label( "ActivateGameObject " + " Enable=" + pmCommsTool.FsmBoolToString(ago.activate) + " Recursive=" + pmCommsTool.FsmBoolToString(ago.recursive.Value) + " on GameObject " + targetGOname , EditorStyles.label); } } } else { i = ii - 1; break; } } } } } }