playMaker

Author Topic: How to find all missing actions in the project?  (Read 2159 times)

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
How to find all missing actions in the project?
« on: March 17, 2015, 06:31:29 PM »
Hello Hutong Games!

Before you read this long post, if the answer is "not possible" I'm okay with that!

We're doing a cleanup pass right now. Not sure what triggers this, but sometimes PlayMaker scans the project for all PlayMakerFSMs and it'll spit out hundreds of errors about "Could not create action... Maybe a script is missing?" And indeed, the custom action scripts have been deleted.

I wrote an editor script, not runtime, to go through every prefab in the project and find every PlayMakerFSM. However, when I try going through each state and look up every action, there does not seem to be a way to identify which actions have had their scripts removed and which actions are valid.

I think I need to go through the ActionData found in each FsmState, but I think since this is an editor script and the Fsm is not running, none of the actions have been initialized and I can't get any information about them.

Is there a way to find missing actions from an editor script?
« Last Edit: March 17, 2015, 06:41:17 PM by GarthSmith »

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • View Profile
    • Garth Smith's Website
Re: How to find all missing actions in the project?
« Reply #1 on: March 17, 2015, 06:39:02 PM »
More info and our use case:

I can go through our prefabs by hand to find these PlayMakerFsms if I need to. Sometimes they can be nested deep inside a prefab so knowing the GameObject name of the FSMs owner might not help.

We just had a release and now we're doing a clean up pass. Here's the script I wrote with the goal to automate removing all missing actions in the entire project, because our game is in a known good state.

Code: [Select]
static void CheckFsmForMissingActions(PlayMakerFSM fsm)
{
    fsm.Fsm.Init(fsm);
    foreach (FsmState s in fsm.Fsm.States)
    {
        for (int n = 0; n < s.ActionData.ActionCount; n++)
        {
            FsmStateAction anAction = s.ActionData.CreateAction(s, n);
            // This if statement is *never* true.
            // So this log message never appears.
            if (anAction == null) Debug.Log("Got a null action!");
        }
        FsmStateAction[] actions = s.ActionData.LoadActions(s);
        for (int n = 0; n < actions.Length; n++)
        {
            // Always reports action.Name as "" with ErrorCheck() ""
            Debug.Log("Inside state " + s.Name + " we found action " +
                actions[n].Name + " which spits out error check " +
                actions[n].ErrorCheck());
            // This does not seem to work either.
            if (actions[n].GetType().IsSubclassOf(typeof(MissingAction)))
                Debug.Log("Previous action is of type MissingAction!");
        }
    }
}
« Last Edit: August 30, 2019, 08:25:00 PM by djaydino »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15440
  • Official Playmaker Support
    • View Profile
Re: How to find all missing actions in the project?
« Reply #2 on: March 18, 2015, 02:49:17 AM »
Hi,

 Can you confirm that actually doesn't solve the problem? it seems your script only log about the missing scripts but doesn't actually remove the warnings nor missing entries in states right?

 I'd like to get a working version of this tool, I am facing this sometimes too. But ideally sometimes I woudl like to replace the missing script with a different script, just because I renamed it, so maybe there is even a way to replace instead of simply remove.


 Bye,

 Jean

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 628
    • View Profile
Re: How to find all missing actions in the project?
« Reply #3 on: August 30, 2019, 10:57:31 AM »
REVIVE!


I second the request for parsing all missing actions and either finding the appropriate scripts or replacing them with others, or even deleting the actions.
When an action can't see its script, it still provides the name of the script, minus the .cs extension.
In other words, in theory it could be possible to parse all actions and relink the blank actions with their scripts.
A switch option to force official actions only (this would be the default) would be nice, so the tool would first look for missing scripts from official actions. Switching to "external actions" (3rd party, custom, etc.) would, instead, go looking for all .cs-type action scripts outside of Playmaker's official actions folder.

Some other options I can't think of right now could allow the user to narrow the research, which might be nice in order to go faster.
Scene, date, size, filter n Game Objects, state name, FSM template, ignore/allow instances (would be logical to have ignore on by default, since editing an instance's FSM breaks the link to the prefab), prefabs only (only looks in Assets, obviously; maybe coud be renamed 'Assets only'... probably), etc.

The entire parsing process could be stopped (cancel button) and there would be a gauge with a counter of total missing actions found.

Once the list would be built, the user could do the following operations:

  • Relink: (order) Looks for the script with the same name and repairs the reference.
  • Change: (order) Pop up to find the script. This is a manual operation that cannot be automated UNLESS a by default script is specified in the field next to this order [...].
  • Remove: (order) Deletes the action in the state.
  • Clean FSMs: (bool) A flag that's off by default. Only applies if the Remove process is used. It will check if the state holding the action is empty and if yes, said state will be deleted.
  • Cycle All: (bool) A flag that's off by default and would cycle through the entire list, dealing with each case found before automatically moving to the other (will not work with 'Change' operation unless a default script is specified). With this flag off, the user would either have to press NEXT or select one of the missing actions in the list. With this flag on, the tool starts from the top of the list unless the user selects a specific action in the list to start from (therefore changing the starting index). Will not loop back to the top, logically.

For the sake of a proper UX, the order buttons should remain somewhere, possibly at the top of the list, so even if the list is long and you have scrolled to its bottom, you can still reach the buttons and other options easily.
And to mimic what is in the Ecosystem, flying the cursor over a line could show the buttons at the right side of the missing action's line you're highlighting (yes, a highlight might be nice, subtle and all that).

A counter for the number of processed faulty actions would be nice too.
If states are to be deleted, a list of such deleted states (and their respective FSMs, with a goto button for each of them) should be seen too, maybe as a popup.
« Last Edit: February 19, 2020, 05:15:48 AM by Broken Stylus »

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 628
    • View Profile
Re: How to find all missing actions in the project?
« Reply #4 on: September 01, 2019, 12:59:02 PM »
Some other options I can't think of right now could allow the user to narrow the research, which might be nice in order to go faster.
Scene, date, size, filter n Game Objects, state name, FSM template, ignore/allow instances (would be logical to have ignore on by default, since editing an instance's FSM breaks the link to the prefab), prefabs only (only looks in Assets, obviously; maybe coud be renamed 'Assets only'... probably), etc.

I forgot the most obvious, action name. Perhaps action category too?

Looking at it, this tool need not be limited to missing actions only. There might be cases where you want to change all given copies of a specific working action with another one.