- Home /
Load a motion/animation clip from script
Hey,
I've been trying to load via script at runtime an animation clip, with no luck. I've tried several methods, but I couldn't find one that works. Our animations source is a fbx file, where in the inspector contains two childs : The animation clip file, that can be edited, etc, and the root of the skeleton ( that when the object is instianted in the scene contains the bone hierarchy ).
So far, what I've tried, following many suggestions and answers around the unity site, is to :
GameObject animResource = Resources.Load("MyAssetName") as GameObject;
// animResource is valid, but... animResource.animation is NULL.
//So, I can't really use animResource.animation.clip or animResource.animation.GetClip("MyAssetAnimationName")
GameObject animClip = Resources.Load("MyAssetName") as AnimationClip;
// animClip is NULL
I could find a "workaround" exposing in a monobehavior a public variable animation clip, and then visually set it in the inspector, but that totally misses the point of the tool I'm doing... so for this to work properly I need to be able to load via script an animation clip ( not necessarily required at runtime )
Your answer
Follow this Question
Related Questions
Allowing users to import their own UnityScript/JavaScript into the game at run time 1 Answer
How to create animation event at specific keyframe at runtime 2 Answers
Unknown Error. 3 Answers
Generating script runtime 1 Answer
How can you make a generated animation work with a humanoid avatar? 1 Answer