Directly on the code:
//Animation name Private Const stringAnim_name ="Take 001"; //Model Objects PrivateGameobject obj =NULL; //Animation Length Private floatAnimlegth=0f; //Animation Components PrivateAnimation m_animation=NULL; Chestnut code://Get model Animations//obj = Gameobject.find ("man"); //get the playback length of the animation; you should get the animation component after the old version can get obj.animation.animation[anim_name].length,5.x directlyM_animation = obj. Getcomponent<animation>(); Animlegth=m_animation[anim_name].length; //Play Animation: 1M_animation.play ();//Play the default animationM_animation.play ("xx");//Play xx animation, the default is to stop the same layer of other animations; function with M_animation.play ("xx", Playmode.stopsamlayer);M_animation.play ("xx", Playmode.stopall);//Play xx animation, all currently playing animations stop//2: Fade the animation with the name animation within a certain amount of timeM_animation.crossfade (string: Animation); M_animation.crossfade (string: Animation,float: Time); M_animation.crossfade (string: Animation,float: Time,playmode:playmode); //determine if the animation is finished; Normalizedtime: Range 0~1, 0 is the beginning of the action, 1 is the end of the action, but for animation like useless, animator is possible, suggest can try, Determine if the value of Normalizedtime is in 0.8~0.9 attempt, or other timing/delegate if(M_animation.isplaying ("xx") && m_animation["xx"].normalizedtime >=1) //Rewind Animationm_animation["xx"].speed = -1f*set the animation playback speed; //stop playing an animationM_animation.stop (); M_animation.stop ("xx");
Unity3d Basic API for animation animation player