protected override void UpdateSubclass()
    {
        // A few examples of how to use MovieSpeed and MovieTime
        ++counter;

        // Start playing after 60 frames have passed
        if (counter == 60)
        {
            binkQuad.GetComponent <icBinkMaterial>().getBinkPlayOptions().movieSpeed = 1.0f;
        }

        // Skip to 200 seconds after 180 frames have passed
        if (counter == 180)
        {
            BinkPlayOptions bpo = binkQuad.GetComponent <icBinkMaterial>().getBinkPlayOptions();
            bpo.loopMovie = true;
            bpo.movieTime = 200.0f;
        }
    }
Пример #2
0
    private IEnumerator CallPluginAtEndOfFrames()
    {
        while (true)
        {
            // Wait until all frame rendering is done
            yield return(new WaitForEndOfFrame());

            if (!this.movieLoaded)
            {
                continue;
            }
            BinkPlayOptions bpo = this.getBinkPluginOptions();

            if (bpo == null)
            {
                continue;
            }


            if (bpo.playAfterSeconds > 0f)
            {
                if (bpo.movieSpeed > 0f)
                {
                    // Simple delay before movie starts playing
                    bpo.playAfterSeconds -= this.getDeltaTime();
                }
            }
            else
            {
                bpo.movieTime += bpo.movieSpeed * this.getDeltaTime();
            }

            // We want bink to render the first frame even if playAfterSeconds is still counting down,
            // so everything below gets run regardless

            if (Type == BinkPluginType.Overlay ||
                (Type == BinkPluginType.GPUTexture && !usingOpenGL()))
            {
                CallPluginRenderLoop();

                // Issue a plugin event with arbitrary integer identifier.
                // The plugin can distinguish between different
                // things it needs to do based on this ID.
                // For our simple plugin, it does not matter which ID we pass here.
                GL.IssuePluginEvent(1);
            }
            else
            {
                if (Movie.Bink != IntPtr.Zero)
                {
                    //
                    // Notify plugin we're about to update Bink
                    //
                    Bink.BINKSUMMARY summary = new Bink.BINKSUMMARY();
                    Bink.BinkGetSummary(Movie.Bink, ref summary);
                    if (Bink.BinkWait(Movie.Bink) == 0)
                    {
                        BinkRenderPreUpdate(Movie.Bink, Movie.TextureSet, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

                        //
                        // Decompress a frame
                        //
                        Bink.BinkDoFrame(Movie.Bink);

                        //
                        // if we are falling behind, decompress an extra frame to catch up
                        //
                        while (Bink.BinkShouldSkip(Movie.Bink) != 0)
                        {
                            Bink.BinkNextFrame(Movie.Bink);
                            Bink.BinkDoFrame(Movie.Bink);
                        }

                        BinkConvertToTexture(Movie);

                        //
                        // Keep playing the Movie.
                        //
                        Bink.BinkNextFrame(Movie.Bink);
                        BinkRenderPostUpdate(Movie.Bink);
                    }
                }
            }
        }
    }