コード例 #1
0
    public bool Update()
    {
        bool result = false;

        AVProLiveCameraManager.ConversionMethod method = AVProLiveCameraManager.Instance.TextureConversionMethod;

#if AVPRO_UNITY_4_X || UNITY_3_5
        if (method == AVProLiveCameraManager.ConversionMethod.Unity4 ||
            method == AVProLiveCameraManager.ConversionMethod.Unity35_OpenGL)
        {
            // We update all the textures from AVProLiveCameraManager.Update()
            // so just check if the update was done
            int lastFrameUploaded = AVProLiveCameraPlugin.GetLastFrameUploaded(_deviceIndex);
            if (_lastFrameUploaded != lastFrameUploaded)
            {
                _lastFrameUploaded = lastFrameUploaded;
                result             = true;
            }
            return(result);
        }
#endif

#if UNITY_3_4
        // Update the OpenGL texture directly
        if (method == AVProLiveCameraManager.ConversionMethod.Unity34_OpenGL)
        {
            result = AVProLiveCameraPlugin.UpdateTextureGL(_deviceIndex, _texture.GetNativeTextureID());
            GL.InvalidateState();
        }
#endif

#if !AVPRO_UNITY_4_X
        // Update the texture using Unity scripting, this is the slowest method
        if (method == AVProLiveCameraManager.ConversionMethod.UnityScript)
        {
            result = AVProLiveCameraPlugin.GetFramePixels(_deviceIndex, _framePointer, _bufferIndex, _texture.width, _texture.height);
            if (result)
            {
                _texture.SetPixels32(_frameData);
                _texture.Apply(false, false);
            }
        }
#endif

        return(result);
    }