Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

iOS crashes game but android works like charm

Discussion in 'Scripting' started by DukeNuke3m, Feb 11, 2019 at 10:32 AM.

  1. DukeNuke3m

    DukeNuke3m

    Joined:
    Apr 28, 2016
    Posts:
    19
    I have created a game in Unity and published it on Android,it works on all types of phones,tested Note9 and P20 as well as Samsung Tab 2 from 2011 and some LG from 2010. It all works without a single lag or crash.
    When i deploy game on iOS the core features works well,actually everything works well except when you want to take screenshot of a game,then it crashes all
    This is the code used for Screenshot

    Code (CSharp):
    1.        takeHiResShot = false;
    2.         Debug.Log("Started Taking ScreenShot");
    3.         Flash.SetActive(true);
    4.          RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
    5.          cam.targetTexture = rt;
    6.         Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
    7.         cam.Render();
    8.         RenderTexture.active = rt;
    9.         screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0);
    10.         cam.targetTexture = null;
    11.         RenderTexture.active = null;
    12.         //Destroy(rt);
    13.         byte[] bytes = screenShot.EncodeToPNG();
    14.         filename = ScreenShotName(resWidth, resHeight);
    15.  
    16.         FullSharePath = "/storage/emulated/0/GarderobaShots/" + filename + ".png";
    17.  
    18.         Texture2D textu = new Texture2D(900,1320, TextureFormat.RGBAFloat, false);
    19.         textu.LoadImage(bytes);
    20.         textu.Apply();
    21.         spr = Sprite.Create(textu ,new Rect(0.0f, 0.0f, textu.width, textu.height), new Vector2(1f, 1f), 100.0f);
    22.  
    23.         ShareAbleObject.transform.GetChild(1).gameObject.GetComponent<Image>().sprite = spr;
    24.         ShareAbleObject.SetActive(true);
    25.         NativeGallery.SaveImageToGallery(textu, "AmazingGirlsShots", filename + ".png");
    26.        
    27.         takeHiResShot = false;
    28.         Debug.Log("Ended ScreenShot");
    Can you please help me out,what is wrong here?
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,198
    Did you check the crash logs on the iOS device?
     
    xVergilx likes this.
  3. DukeNuke3m

    DukeNuke3m

    Joined:
    Apr 28, 2016
    Posts:
    19
    yes i did,and it doesnt show any errors,debug logs go on,and silently crashes...
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,198
    Wait, the iOS device crash logs doesn't show a reason it crashed? I'm not talking unity stuff, the device itself under the iOS analytics has no logs for crashes?

    If this is the case, probably not going to be able to help you. But it looks like you are using the NativeGallery plugin, so perhaps just make sure you didn't miss a step to make sure it worked right on iOS.