Unity3d 工具方法

来源:互联网 发布:淘宝省市区三级联动js 编辑:程序博客网 时间:2024/06/18 17:11

一、Unity3d Animation 正序、倒叙播放(从当前的位置帧)

    void Play(Animation animation,float speed = 1.0f)
    {
        float currentTime = animation[animation.clip.name].time;
        animation[animation.clip.name].time = currentTime;
        animation[animation.clip.name].speed =1* speed;
        animation.Play(animation.clip.name);
    }


   void Rewind(Animation animation,float speed = 1.0f)
    {
        float currentTime = animation[animation.clip.name].time;
        animation[animation.clip.name].time = currentTime;
        animation[animation.clip.name].speed =-1* speed;
        animation.Play(animation.clip.name);
    }


二、unity3D 调用手机外部播放器、针对安卓、苹果手机;API 5.4.2


 public static void PlayVideo(string file,FullScreenMovieControlMode fullScreenMovieControlMode=FullScreenMovieControlMode.Full)
    {
        Handheld.PlayFullScreenMovie(file, Color.black, fullScreenMovieControlMode);
    }

    public static void PlayVideo(string file, Color bgColor,FullScreenMovieControlMode fullScreenMovieControlMode = FullScreenMovieControlMode.Full)
    {
        Handheld.PlayFullScreenMovie(file, bgColor, fullScreenMovieControlMode);
    }

    public void PlayVideo(string file, System.Action callbabck)
    {
        StartCoroutine(IEPlayVideo(file, callbabck));
    }
    
    IEnumerator IEPlayVideo(string file,System.Action callbabck, FullScreenMovieControlMode fullScreenMovieControlMode = FullScreenMovieControlMode.Full)
    {
        Handheld.PlayFullScreenMovie(file, Color.black, fullScreenMovieControlMode);
        yield return new WaitForEndOfFrame();
        if (callbabck != null)
        {
            callbabck();
        }
    }

原创粉丝点击