11-03-2024 09:23 PM - last edited on 11-03-2024 09:33 PM by LordArceus
我用的Unity版本是2021.3.6
我想实现局部截图的功能,通过下述这个方法
public static void SaveRenderTexture(RenderTexture rt, string folderName) { var saveDir = Application.persistentDataPath + "/" + folderName + "/"; if (!Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } var prev = RenderTexture.active; RenderTexture.active = rt; var png = new Texture2D(rt.width, rt.height, TextureFormat.ARGB32, false); png.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0); var bytes = png.EncodeToPNG(); var pathNow = saveDir + DateTime.Now.Ticks + ".png"; var file = File.Open(pathNow, FileMode.Create); var writer = new BinaryWriter(file); writer.Write(bytes); file.Close(); Object.DestroyImmediate(png); RenderTexture.active = prev; }
1.在Vulkan的情况下打包到Quset 截出的图片只有显示下面一半或者部分,其余部分是黑色的但编辑器模式下该功能是正常的。
2.用OpenGLES3也能正常显示,但会导致其余的模型渲染层级不对,部分模型没有显示,unity提示“Symmetric Projection is only supported on Quest 2 and QuestPro with Vulkan and Multiview.”
似乎在我的项目里Vulkan和OpenGLES3只能选一个或者有冲突,请问您知道原因或解决方法吗