unity-game-engine - 仅在 Android 上渲染纹理黑色

标签 unity-game-engine camera rendering

如果相机没有移动,我想在纹理中绘制相机 View 并在 Canvas 中显示纹理。我在 Android 上运行它,然后得到黑色纹理,但对于 WebPlayer 来说很好!

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;
}

最佳答案

我认为这可能对某人有帮助......

意外地重复了同样的问题...在 iOS 和 Droid 上都有效。 然后禁用相机清除功能,嘿,请注意...在 iOS 上可以工作,但在 Android 上却是黑色的。 将相机清晰更改回仅 Z 深度...iOS 和 Droid 都再次工作。

因此请尝试更改相机清晰度设置。

关于unity-game-engine - 仅在 Android 上渲染纹理黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35196619/

相关文章:

ios - 在 Swift 中生成图像

unity-game-engine - 从另一个游戏对象的脚本设置变换

c# - 如何将物体从碰撞点移动到物体末端 |统一

android - 允许用户从相机和图库中选择图像不适用于已安装的应用程序,如 Camera360

ios/iphone 照片连拍模式 api

javascript - 在网页上呈现 PDF

unity-game-engine - 对 'Script Execution Order' 的任何更改都会立即恢复

c# - 如何从维护其组件和属性的服务器加载 Unity 中的游戏对象?

java - 在wallpaperservice中显示camera2预览

javascript - 在 Angular 函数不起作用后调用 jquery 选择器(渲染问题?)