Forum rules - please read before posting.

Deleting Actions

After some refactoring I found that a couple of actions that I created are unnecessary for my project, but deleting them from project files seems to end up in a couple of Missing Behaviour references that are not linked to any gameObject in the scene. And when I call something like this:


private static void FindLeftoverActions ()
    {
        Action[] allActions = Resources.FindObjectsOfTypeAll<Action>();
        List<Action> actionMegalist = new List<Action>();
        ActionList[] allLists = Resources.FindObjectsOfTypeAll<ActionList>();
        for (int i=0; i<allLists.Length; i++)
        {
            for (int e=0; e< allLists[i].actions.Count; e++)
            {
                if (!actionMegalist.Contains(allLists[i].actions[e]))
                    actionMegalist.Add(allLists[i].actions[e]);
            }
        }
        ActionListAsset[] allLists2 = Resources.FindObjectsOfTypeAll<ActionListAsset>();
        for (int i = 0; i < allLists2.Length; i++)
        {
            for (int e = 0; e < allLists2[i].actions.Count; e++)
            {
                if (!actionMegalist.Contains(allLists2[i].actions[e]))
                {
                    actionMegalist.Add(allLists2[i].actions[e]);
                }
            }
        }
        Debug.Log("Linked actions count: "+actionMegalist.Count);
        Debug.Log("Total actions count: " + allActions.Length);
    }

I get around 1000 of linked actions and 1700 total actions. (also total actions keeps growing over time while working with the project). How would I go about deleting actions from the project? (The "AC Game Editor -> Actions -> (Select Action) -> Search all instances" finds no results)

Comments

  • edited November 2016
    Deleting an Action script while ActionLists exist that make use of it will definitely cause problems.  I hope you have a back up of it!

    An Action can't be removed from an ActionList without also re-routing the Actions that surround it.  This happens automatically if you delete an Action within the ActionList Inspector or ActionList Editor window.

    You will first need to plug the old Action script back into the Actions Manager, and then use the Manager to locate any instances of it.  Selecting an Action in the Actions Manager brings up a Search all instances button, which should comb through all your ActionLists (asset or otherwise) for its use.  You can then remove them before removing the Action script file itself.

    Edit: Actually, one or two assets are missed out of the search feature, related to the Inventory and Menu Managers.  If your Actions used there, probably better to wait for AC v1.55 which will update the search code.
  • Thanks, I'll wait for the new version, although we already have a lot of modified code, so updating to new versions is getting costlier.

    Anyway, since you'll be looking into the Search code. There is another issue with Search all instances. If you create an action, then assign it, then change the title, the old actions don't seem to get found (since their title doesn't get updated i think). I modified to type comparison. When creating ActionType object I added:

    public ActionType (string _fileName, Action _action)
      {
                actionType = _action.GetType(); //also gets carried in the copy/clone method;
    .....
    }

    And tried comparing using it. Probably not a perfect solution, but it helped find more elements than the initial stock find attempt.
  • Good spot, I'll look into that as well.
  • Well, if there was not enough time to remove them, or I felt it was too risky, I would probably just turn them into blank custom actions. That way they wouldn't execute any real code, and I wouldn't risk ruining the wiring in the actionlists... course that's a matter of time and preference I guess. I just prefer to be safe.
  • Hmm, maybe, Alverik. Perhaps i could store them in some 'dump' action group. Still, for now I feel like pursuing this.

    I just reworked another action and managed to delete it without any issues. Maybe the one that threw 'missing Behavior' Warnings was involved in the actions rewiring bug or remained somehow else. Maybe there is a way to check from inside the action whether it is involved in any actionLists or groups or at least does it have an entry and an exit (is in a chain)?
  • Data for connections between Actions are stored in the "higher" Action, so an Action doesn't have any info about it's entry point.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.