Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: wohoa on May 21, 2014, 05:24:06 AM

Title: How to get Fsm variable used count?
Post by: wohoa on May 21, 2014, 05:24:06 AM
Hi, everybody.
  Our designer use many fsm component to control skill, buff, and so on.
Now, in these fsm component, has many fsm variable never used, I want to check these variable used count when load perfab, if some variable used count is zero,  display some message to designer.
How do to get Fsm variable used count?
thx
Title: Re: How to get Fsm variable used count?
Post by: billsclass on May 21, 2014, 07:10:51 PM
I am not sure how to get the variable use into a variable at run time, but if you look at the variables panel, it shows you the number of times each variable is used.
Title: Re: How to get Fsm variable used count?
Post by: Alex Chouls on May 21, 2014, 07:40:40 PM
Look into the HutongGames.PlayMakerEditor.FsmSearch class. It's not documented so you'll have to poke around a bit.

The FsmSearch class analyses FSMs and caches info in a format that can be more easily searched.

For a quick answer to your question, use this:

public static int GetVariableUseCount(Fsm fsm, NamedVariable variable)
Returns the number of times the variable is used in the fsm.

If you want to explore further:

public static FsmSearch Get(Fsm fsm)
Gets cached search info associated with an Fsm.

public static void Update(Fsm fsm)
Update the search info associated with an Fsm.

Actually there's too much to document here! I'll try to find some time to document it on the wiki...

NOTES:
Title: Re: How to get Fsm variable used count?
Post by: coxy17 on August 24, 2018, 02:04:59 PM
Hi Alex,

Do you have any examples of using HutongGames.PlayMakerEditor.FsmSearch ?
I want to use it in a custom EditorWindow but not sure how to reference it outside of the editor?

Do you have a class name with a static method?
FsmSearch.GetVariableUseCount()?

Nick