/// <summary>
    /// Capture image with the view of the target camera. Return a RenderTexture.
    /// </summary>
    /// <param name="camera">Target Camera.</param>
    /// <param name="scale">Apply this scale to capture image. (Scale the image size down to the minimum of 0.1X and up to 4X)</param>
    /// <param name="onCaptured">On captured callback, return the captured RenderTexture.</param>
    /// <param name="blitToNewTexture">Create and return a new RenderTexture, so that will not be removed by the Clear method.</param>
    public void CaptureRenderTextureWithCamera(Camera camera, float scale, Action <RenderTexture> onCaptured = null, bool blitToNewTexture = true)
    {
        UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);

        RegisterRenderCamera(camera);
        CameraOnRender camOnRender = camera.gameObject.GetComponent <CameraOnRender>();

        if (camOnRender != null)
        {
            camOnRender.SetOnCaptureCallback((RenderTexture rTex) => {
                _renderTexture = rTex;
                if (m_MainOnCaptured != null)
                {
                    m_MainOnCaptured.Invoke();
                }
                if (onCaptured != null)
                {
                    onCaptured(_renderTexture);
                }
            }, scale, blitToNewTexture);
        }
        else
        {
            Debug.LogWarning("Require this camera to be registered with method RegisterCaptureCamera!");
        }
    }
    /// <summary>
    /// Capture image with the view of the target camera. Return a Texture2D.
    /// </summary>
    /// <param name="camera">Target Camera.</param>
    /// <param name="onCaptured">On captured callback, return the captured Texture2D.</param>
    /// <param name="targetWidth">The width for the texture.</param>
    /// <param name="targetHeight">The height for the texture.</param>
    public void CaptureWithCamera(Camera camera, Action <Texture2D> onCaptured = null, int targetWidth = 0, int targetHeight = 0)
    {
        UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);

        RegisterRenderCamera(camera);
        CameraOnRender camOnRender = camera.gameObject.GetComponent <CameraOnRender>();

        if (camOnRender != null)
        {
            camOnRender.SetOnCaptureCallback((Texture2D tex) => {
                _texture2D = tex;
                if (m_MainOnCaptured != null)
                {
                    m_MainOnCaptured.Invoke();
                }
                if (onCaptured != null)
                {
                    onCaptured(_texture2D);
                }
            }, targetWidth, targetHeight);
        }
        else
        {
            Debug.LogWarning("Require this camera to be registered with method RegisterCaptureCamera!");
        }
    }