Get just the animation clip from assetbundle

Not sure if you can do this or not, but the idea is: I have a character with over 200 animations, but on any given scene only about 16 will be loaded, and those 16 could vary from scene to scene so should be loaded on the fly at scene startup.

So what I’d like to do is put all the extra animations in separate asset bundles, then load those bundles to get the animation out of them so I can call AddClip on my main character.

I am managing my various asset bundles inside a resource manager with a class I made called “Bundle” and they have the following function inside of them:

	public GameObject GetNewInstance()
	{
		// Create an instance of this
		// resource and return it
		if(assetBundle)
		{
			Object o = assetBundle.mainAsset;
		
			if(o)
			{
				GameObject NewInstance = (GameObject)MonoBehaviour.Instantiate(o);
				Debug.Log("Bundle: Created new instance of `" + m_szName + "`.");
				m_arrInstances.Add(NewInstance);
				return NewInstance;
			}
		}
		
		Debug.Log("Bundle: Could not instantiate `" + m_szName + "`!");
		return null;
	}

So to add the support for just getting the animation out of one of these asset bundles I want to make another function called GetAnimationFromBundle(), but I don’t want to make an instance of it or anything, just get the animation clip out of it so I can add it to the already existing character - make sense?

Assuming the function could literally just return the first animation of the loaded object it finds or null if none - is there a way to do this without having to instantiate the object first?

Note - I’ve tried casting Object to GameObject which fails as one would probably assume.

… Ok nevermind, turns out it was the bundle itself that was messed up. I was able to straight cast from Object to GameObject and return just the animation.