playMaker

Author Topic: How to get Fsm variable used count?  (Read 2030 times)

wohoa

  • Playmaker Newbie
  • *
  • Posts: 3
How to get Fsm variable used count?
« 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

billsclass

  • Playmaker Newbie
  • *
  • Posts: 11
Re: How to get Fsm variable used count?
« Reply #1 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.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: How to get Fsm variable used count?
« Reply #2 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:
  • This editor API has not been tested outside of its use in the PlayMaker Editor. Exercising it outside of that context may expose dependencies/bugs
  • There is a bug where variable usage inside a Run FSM action is not currently counted.

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: How to get Fsm variable used count?
« Reply #3 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