Make a child animation clip Private to that controller?

So, I was working on a helper script to attach child animations to their controllers; trying to clean up my project some. I’ve found it’s nearly impossible to easily attach existing animations, but I found a good way to create new animations that I could easily copy the animation data into. The only issue I’ve ran into so far is that the clips I create are still accessible to other animator controllers. When you auto-generate an animation for say a button, those clips are private to that controller only, and cannot be seen or accessed anywhere else. I would like to be able to do the same, but so far I’ve found nothing in all of my searching and tests. So far the closest I’ve come was using the clip’s HideFlags, but that ended up hiding it from its own controller as well.

Has anyone else had any luck doing this? I can continue to work without it, but it would be a really useful piece of code for cleaning up my hierarchies and references in the project. Here’s my code so far, just for reference and anyone who wants to try to solve this.

#if UNITY_EDITOR
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Animations;

[ExecuteInEditMode]
public class ChildAnimToController : MonoBehaviour {
	public AnimatorController Anim;
	public List<string> Clips;

	public bool Execute;
	
	// Update is called once per frame
	void Update () {
		if(Execute)
		{
			Execute = false;
			ParentAnimations();
		}
	}

	void ParentAnimations()
	{
		foreach(string clipName in Clips)
		{
			AnimationClip animationClip = AnimatorController.AllocateAnimatorClip(name);
			animationClip.name = clipName;
			AssetDatabase.AddObjectToAsset(animationClip, Anim);
			Anim.AddMotion(animationClip);
			AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(animationClip));
		}
	}
}
#endif

Hi @Kabutak! Can you clarify what you mean? It seems like what you want is something along the lines of AssetDatabase.AddObjectToAsset (), but you say that

When you auto-generate an animation for say a button, those clips are private to that controller only, and cannot be seen or accessed anywhere else.

but this is not true. Those clips that are generated are still just assets in your project and can be referenced anywhere by anything (i.e. selected in the object picker popup, dragged from the project view to an object reference field, etcc).