Unity游戏在iOS上崩溃,但在Android上不崩溃

时间:2019-01-13 18:51:07

标签: c# ios xcode unity3d crash

我制作了一个应用程序来拍摄屏幕图像,并将其保存在Gallery中,其名称是我使用DateTime类和自己的前缀给出的。 Android上的代码运行完美,当您按下按钮时,它将截屏并完成所有操作。 但是故事在iOS上并不相同。一旦按下按钮,它就会崩溃。这是代码:

Flash.SetActive(true);
RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
cam.targetTexture = rt;
Texture2D screenShot = new Texture2D(resWidth, resHeight, 
TextureFormat.RGB24, false);
cam.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
cam.targetTexture = null;
RenderTexture.active = null;
Destroy(rt);
byte[] bytes = screenShot.EncodeToPNG();
filename = ScreenShotName(resWidth, resHeight);

FullSharePath = "/storage/emulated/0/GarderobaShots/" + filename + ".png";

Texture2D textu = new Texture2D(900,1320, TextureFormat.RGBAFloat, false);
textu.LoadImage(bytes);
textu.Apply();
spr = Sprite.Create(textu ,new Rect(0.0f, 0.0f, textu.width, textu.height), 
new Vector2(1f, 1f), 100.0f);

ShareAbleObject.transform.GetChild(1).gameObject.GetComponent<Image> 
().sprite = spr;
ShareAbleObject.SetActive(true);
NativeGallery.SaveImageToGallery(textu, "AmazingGirlsShots", filename + ".png");

takeHiResShot = false;

快速介绍代码 它使用我拥有的某些相机(较小的相机,具有不同的画布(仅文本))切换场景的MainCamera,然后激活我称为Flash的对象,该对象是屏幕上的白色Flash,它本身就消失了 然后,它从屏幕上渲染纹理并将其保存在

Texture2D textu

“完全共享”路径是此文件将被存储的路径,因此用户可以共享或从游戏中看到它。

NativeGallery.SaveImageToGallery(textu, "AmazingGirlsShots", 
filename".png"); 

这是我为ios和android所使用的插件,用于刷新图库以在图库中显示图像,否则它仅在手机中的某个位置 我认为这不是问题,因为许多人使用它的检查插件

0 个答案:

没有答案