将RenderTexture转换为Texture2D,为了读取RenderTexure的像素

The trick here is to create a new Texture2D, and then use the ReadPixels method to read the pixels from the RenderTexture to the Texture2D, like this:

RenderTexture.active=myRenderTexture;
myTexture2D.ReadPixels(newRect(0,0,myRenderTexture.width,myRenderTexture.height),0,0);
myTexture2D.Apply();
myTexture2D.getPixel(......);

原理就是使用 Texture2D.ReadPixels 将当前(RenderTexture.active)纹理读取到 Texture2D中。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,977评论 0 23
  • 孩子,还有51天,你就三周岁了。 很多时候,不能陪伴。我会担心你吃不好,穿不暖,怕你孤单。我同你说话的时候,尽量蹲...
    莫愁塘主阅读 300评论 4 10
  • 早晨起床挤牙膏准备刷牙,忽然觉得手中的牙膏像极了最近的生活,是的,牙膏需要挤一挤才会落到牙刷上,生活也需要挤一挤才...
    先生少年阅读 248评论 0 2
  • 我也曾背着书囊 走在烈阳高照的道路旁 揣在心中的那份梦想 在蓝天白云里翱翔 风吹散了方向 泪水有过迷茫 却让我变得...
    青卄柳阅读 328评论 0 1
  • 近来可躁了,有太多事情皆静不下心来做。尤其是上次去完广州,看了Vans的一场Teambuilding,本身是个很美...
    鸡仔说阅读 270评论 0 0