Exemple #1
0
    private bool UpdateTexture()
    {
        bool result = false;

        AVProQuickTimeManager.ConversionMethod method = AVProQuickTimeManager.Instance.TextureConversionMethod;

#if AVPRO_UNITY_4_X || UNITY_3_5
        if (method == AVProQuickTimeManager.ConversionMethod.Unity4 ||
            method == AVProQuickTimeManager.ConversionMethod.Unity35_OpenGL)
        {
            // We update all the textures from AVProQuickTimeManager.Update()
            // so just check if the update was done
            int frameUploadCount = AVProQuickTimePlugin.GetFrameUploadCount(_movieHandle);
            if (_frameUploadCount != frameUploadCount)
            {
                _lastFrameUploaded = AVProQuickTimePlugin.GetLastFrameUploaded(_movieHandle);;
                _frameUploadCount  = frameUploadCount;
                result             = true;
            }
            result = true;
            return(result);
        }
#endif

#if UNITY_3_4
        // Update the OpenGL texture directly
        if (method == AVProQuickTimeManager.ConversionMethod.Unity34_OpenGL)
        {
            result = AVProQuickTimePlugin.UpdateTextureGL(_movieHandle, _rawTexture.GetNativeTextureID());
            GL.InvalidateState();
        }
#endif

#if !AVPRO_UNITY_4_X
        // Update the texture using Unity scripting, this is the slowest method
        if (method == AVProQuickTimeManager.ConversionMethod.UnityScript)
        {
            bool formatIs422 = (_sourceVideoFormat == AVProQuickTimePlugin.PixelFormat.YCbCr);
            if (formatIs422)
            {
                result = AVProQuickTimePlugin.GetFramePixelsYUV2(_movieHandle, _frameHandle.AddrOfPinnedObject(), _rawTexture.width, _rawTexture.height, ref _lastFrameUploaded);
            }
            else
            {
                result = AVProQuickTimePlugin.GetFramePixelsRGBA32(_movieHandle, _frameHandle.AddrOfPinnedObject(), _rawTexture.width, _rawTexture.height, ref _lastFrameUploaded);
            }
            if (result)
            {
                _rawTexture.SetPixels32(_frameData);
                _rawTexture.Apply(false, false);
            }
        }
#endif

        return(result);
    }