public void Initialize() { if (!Application.isPlaying) { return; } if (_initialized) { return; } //Debug.Log("Initializing "+target); _initialized = true; if (target == ProxyFsmTarget.FsmComponent) { return; } if (gameObject != null) { fsmComponent = PlayMakerUtils.FindFsmOnGameObject(gameObject, fsmName); } if (fsmComponent == null) { Debug.LogError("Initialized with no FsmComponent found"); } //Debug.Log("Initialized with fsmComponent<"+fsmComponent.FsmName+">"); }
public void Initialize(bool forceRefresh = false) { //Debug.Log("Initializing "+variableTarget+" _initialized:"+_initialized+" forceRefresh:"+forceRefresh); if (_initialized && !forceRefresh) { return; } _initialized = true; _fsmVariables = null; if (variableTarget == ProxyFsmVariableTarget.GlobalVariable) { _fsmVariables = PlayMaker.FsmVariables.GlobalVariables; // Debug.LogWarning("Setting FsmVariables for "+variableTarget); } else { if (variableTarget == ProxyFsmVariableTarget.FsmComponent) { if (_fsmComponent != null) { _fsmVariables = _fsmComponent.FsmVariables; Debug.LogWarning("Setting FsmVariables for " + variableTarget + " _fsmComponent= " + _fsmComponent); } return; } if (gameObject != null) { fsmComponent = PlayMakerUtils.FindFsmOnGameObject(gameObject, fsmName); } if (fsmComponent == null) { _fsmVariables = null; //Debug.LogError("Initialized with no FsmComponent found"); } else { _fsmVariables = _fsmComponent.FsmVariables; //Debug.LogWarning("Setting FsmVariables for "+variableTarget+" _fsmComponent= "+_fsmComponent); } } //Debug.Log("Initialized with fsmComponent<"+fsmComponent.FsmName+">"); }
void SelectFsmFromGameObject(GameObject go) { PlayMakerFSM[] _list = go.GetComponents <PlayMakerFSM>(); _fsmChoices = new string[_list.Length]; for (int i = 0; i < _list.Length; i++) { _fsmChoices[i] = _list[i].FsmName; } if (_fsmChoices.Length == 0) { ErrorFeedbackGui("No Fsm on target"); } else { int _choiceIndex = EditorGUILayout.Popup("Fsm", _target.fsmVariableSetup.fsmIndex, _fsmChoices); if (_choiceIndex != _target.fsmVariableSetup.fsmIndex || _target.fsmVariableSetup.fsmComponent == null) { //GUILayout.Label("finding "+go.name+"/"+_fsmList[__fsmListChoiceIndex]+":" + PlayMakerUtils.FindFsmOnGameObject(go,_fsmList[__fsmListChoiceIndex])); _target.fsmVariableSetup.fsmIndex = _choiceIndex; PlayMakerFSM _fsm = PlayMakerUtils.FindFsmOnGameObject(go, _fsmChoices[_choiceIndex]); if (_fsm == null) { Debug.LogError("Could not find fsm " + _fsmChoices[_choiceIndex] + " on go:" + go.name); _target.fsmVariableSetup.fsmComponent = null; } else { // Debug.LogError("found fsm "+_fsmList[_choiceIndex]+" on go:"+go.name+" "+_fsm.FsmName); _target.fsmVariableSetup.fsmComponent = _fsm; } } } }