如果相机没有移动,我想在纹理中绘制相机 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/