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
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.
{
actionType = _action.GetType(); //also gets carried in the copy/clone method;