How to use .anim file

hii, there is one option project hierarchy, create->Animation.

it creates a blank animation file with .anim format. whts the use of this file, how we can open it.

Is there any tutorial available for that.

Any help will be useful?

Thanks,


edit

Moved from comments:

public void SpreadOpen()
{
    if (animRoot)
    {
        currentAnimation = animRoot["spread open"];
        animRoot["spread open"].speed = Mathf.Abs(openCloseSpeed);
        animRoot.CrossFade("spread open");
    }
} // added missing bracket

public void SpreadClose()
{
    if (animRoot)
    {
        animRoot["spread close"].speed = Mathf.Abs(openCloseSpeed);
        animRoot.CrossFade("spread close");
    }
}

1 Answer

1

Just add it to the animations array of an Animation component. Open the animation window (Unity3d-->window-->Animation) and select the gameobject with the Animation component. Now you can select the animation inside the animation window and you can animate every component on this gameobject.I don't know any tutorials but here's the Unity manual.

Maybe you've a script that turns it off or you added an animation curve that turns the rendere off. You can animate "every" public variable. A boolean like renderer.enabled needs a curve between 0 and 1. If you don't want to animate it just remove the animationcurve from renderer.enabled.

–

i have a script which actually start and close the animation. and also there is some animation added to each fbx, i need to use it. but why it turns off at the time of rendering?

–

It never turns off automatically. As I said you have either a script or an animation that turns it off. Can you post some related code or upload a package containing the related object somewhere? I can't tell you much more since i don't have your project ...

–

i am trying to make a story book, first page will open on click. for that first of all i have created a script called pagecontrollscript.cs in which i have declared this-: public GameObject[] spreadPrefabs; so now i can add number of prefabs in inspector view, and that will be act as my story book pages. then to open that pages,

–

i have created a script, public void SpreadOpen() { if (animRoot) { currentAnimation = animRoot["spread open"]; animRoot["spread open"].speed = Mathf.Abs(openCloseSpeed); animRoot.CrossFade("spread open"); } public void SpreadClose() { if (animRoot) { animRoot["spread close"].speed = Mathf.Abs(openCloseSpeed); animRoot.CrossFade("spread close"); } }

–