Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: coxy17 on December 27, 2017, 08:18:42 AM

Title: API FsmVar get/set 'Category' and get 'Used' count
Post by: coxy17 on December 27, 2017, 08:18:42 AM
Hi,

Im using the API for a custom editor window and i wondered is it possible to get/set the FSM variable 'Category' and also get the 'Used' count of a fsmvar? (image attached).

Nick
Title: Re: API FsmVar get/set 'Category' and get 'Used' count
Post by: Deek on December 27, 2017, 09:16:19 AM
For the categories you need to get the reference to your desired FSM (or iterate through all available FSMs by using Fsm.FsmList or Fsm.SortedFsmList). Of course you also need the PlayMaker using directive:
Code: [Select]
using HutongGames.PlayMaker;and from there on you can get all variables and in there all categories, like so:
Code: [Select]
yourFSM.Variables.CategoriesThis holds an array of all categories in that FSM (the first entry is empty, because it's the default category where all unsorted variables land), which you can get or set (though I couldn't find how to set the category of single fsm-variables).

For reference, here is how I get a list of all categories from a specific FSM in my own debug window:
Code: [Select]
string[] allCategories = activeFSM.Variables.Categories;
for(int i = 0; i < allCategories.Length; i++)
{
    //skip empty categories to only display relevant ones
    if(allCategories[i] == "" || allCategories[i] == null)
    {
continue;
    }
    GUILayout.Label("Category " + i + ": " + allCategories[i]);
}

Unfortunately, I also couldn't figure out how to get the used-count of each variable and I think it only gets calculated inside the PlayMaker Editor window script or somewhere else, but I might be wrong. There could be something in other directives like HutongGames.Utility or a helper function nested inside Fsm.[...], but I haven't found anything related yet.
Title: Re: API FsmVar get/set 'Category' and get 'Used' count
Post by: coxy17 on December 27, 2017, 09:37:10 AM
hi,

thanks for this, but its strange how we cant get the values for the 'category' and 'used' values. But if i find anything soon, ill post it here. But not looking likely.

Nick