Thanks Jean,
One general question: the code above is meant to send a FsmEvent to a FSM, right?
Hi,
- yes, you can optimize this script by caching some of its classes.
Let me guess. It means I need to push the instance creation into the Start() phase, right? I suppose there may be other things from that script I could move too, since I see other "new MoreStuff" lines below the one I quoted, although they are closely related to FSM functions, such as:
- FsmEventTarget _eventTarget = new FsmEventTarget();
- FsmOwnerDefault owner = new FsmOwnerDefault();
- owner.GameObject = new FsmGameObject();
I would consider moving them too into the Start() phase, would that be fine?
- when you send an event, you can set event data by storing it in this HutongGames.PlayMaker.Fsm.EventData, it's the mechanism for it. you normally use GetEventInfos ( and setEventData) actions to access this.
But what is .EventData exactly?
In Playmaker you can send plenty of events at the same time, from different FSMs, each event with its own data set. But there I don't get the syntax as it seems to be pointing to one single element.
I mean, I'd have expected something more like
MyFsmEvent.EventData with EventData being (I'm totally guessing) something like a dictionary considering the kind of stuff that goes in the whole data set of an event.
But with HutongGames.PlayMaker.Fsm.EventData, at no point I even see a reference to a unique event or an instance of something.
HutongGames? Nope. Playmaker? Nope. Fsm? Still nope. And suddenly... EventData!
If I have several events to store data into, how is that even going to work?
Or is there something in that "EventData" that parses and understands that depending on what it is fed with (in this case it's "= eventData") , it will generate a (temporary?) data set for that particular eventData, because eventData contains an ID for the event, plus a series of plenty of other values?
If I have several events, with their own data, would something like this work:
HutongGames.PlayMaker.Fsm.EventData = eventData1;
HutongGames.PlayMaker.Fsm.EventData = eventData2;
HutongGames.PlayMaker.Fsm.EventData = eventData3;
And produce discrete sets of data for each separate event?
To me it doesn't look like it would work. I don't see how the code would have a way to recall the data of event 1, event 2, etc. It looks like a placeholder for one single event, one at a time.
So is .EventData meant to be used for only one event and the coder MUST do everything that is necessary with that event (like sending it, for starters) before using .EventData for another event right after that?