仅在Android上渲染黑色纹理 [英] Render Texture Black on Android Only

查看:304
本文介绍了仅在Android上渲染黑色纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果相机不移动,我想在纹理中绘制相机视图并在画布中显示纹理.我为Android运行它,然后得到了黑色纹理,但是对于WebPlayer来说是很好的!

I want to draw view of camera in texture and show texture in canvas, if camera not moving. I run it for android then I got black texuture, but for WebPlayer is Good!

public RawImage rawImage;

private void Start()
{
   texture = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 32, RenderTextureFormat.ARGB32);
    texture.antiAliasing = 8;
    texture.Create();
}

public void ShowTexture()
{
   camera.targetTexture = texture;
   RenderTexture.active = texture2;
   if (!RenderTexture.active.IsCreated())
      RenderTexture.active.Create();

   camera.Render();

   var texture2d = new Texture2D(camera.targetTexture.width, camera.targetTexture.height, TextureFormat.RGB24, true, true);
   texture2d.ReadPixels(new Rect(0, 0, camera.pixelWidth, camera.pixelHeight), 0, 0);
   texture2d.Apply(false);

   RenderTexture.active = null;
   camera.targetTexture = null;

  rawImage.texture = texture2d;
}

推荐答案

这可能对某人有帮助...

figure this might help someone...

偶然地复制了相同的问题...在iOS和Droid上均可使用. 然后禁用相机清除功能,然后保存...在iOS上可用,但在Android上则为黑色. 更改了相机的清晰度,使其仅恢复为Z深度...,并且iOS和Droid都可以再次使用.

Replicated same issue by accident... working both on iOS and Droid. Then disabled camera clear, and hey presto... works on iOS but black on Android. changed camera clear back to Z-depth only... and both iOS and Droid work again.

因此,请尝试更改相机的清晰设置.

So try changing your camera clear settings.

这篇关于仅在Android上渲染黑色纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆