Richo
Richo

Reputation: 1659

Import existing animation file to unity web player model

I'm trying to import an existing .anim file to an existing unity model. I know how do so it in Unity, and build into a HTML file, but I'm wondering is there a method to do it just using unityscript or javascript? I mean using javascript to load an .anim file into the model in unity web player, if there is any solution, thanks!

Upvotes: 1

Views: 730

Answers (1)

Saturnix
Saturnix

Reputation: 10554

Resource.Load allows you to do just that.

var mdl : GameObject = Resources.Load("Animations/"+ animationFolder+"/" + aName);

    if (!mdl) {

        Debug.LogError("Missing animation asset: Animations/" + animationFolder+"/"+aName + " could not be found.");

    }  else {

        var aClip = mdl.animation.clip;
        charAnimation.AddClip(aClip, aName);
        Debug.Log(charAnimation[aName].name + " loaded from resource file " + animationFolder + "/" + aName + ". Length check: " + charAnimation[aName].length);    

    }

Upvotes: 1

Related Questions