【Unity - 屏幕截图】技术要点

在Unity中想要实现全屏截图或者截取某个对象区域的图片都是可以通过下面的函数进行截取

Texture2D

/// <summary>
    ///   <para>Reads the pixels from the current render target (the screen, or a RenderTexture), and writes them to the texture.</para>
    /// </summary>
    /// <param name="source">The region of the render target to read from.</param>
    /// <param name="destX">The horizontal pixel position in the texture to write the pixels to.</param>
    /// <param name="destY">The vertical pixel position in the texture to write the pixels to.</param>
    /// <param name="recalculateMipMaps">If this parameter is true, Unity automatically recalculates the mipmaps for the texture after writing the pixel data. Otherwise, Unity does not do this automatically.</param>
   public void ReadPixels(Rect source, int destX, int destY, [DefaultValue("true")] bool recalculateMipMaps)
   

Texture2D.ReadPixels() 函数参数可以翻译注释了解用法,比较简单,我下面简单说一下:

source: 读取像素的区域,坐标起点是 左下角,这个要注意

destX: 读取后写入到texture的坐标X

destY: 读取后写入到texture的坐标Y

recalculateMipMaps :

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值