Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Gray Texture And Callback Not Work On Some IOS Devices #144

Open
karadot opened this issue May 27, 2022 · 3 comments
Open

Gray Texture And Callback Not Work On Some IOS Devices #144

karadot opened this issue May 27, 2022 · 3 comments
Labels

Comments

@karadot
Copy link

karadot commented May 27, 2022

Ekran Resmi 2022-05-27 11 42 55
Description of the bug

Attached file on some ios devices shown as gray textures(13 Pro Max, X) and callback not working (X)

Reproduction steps
Used code block for save:

    RectTransform rt = frame.GetComponent<RectTransform>();

    Vector3[] corners = new Vector3[4];
    rt.GetWorldCorners(corners);
    for (int i = 0; i < corners.Length; i++)
    {
        corners[i] = RectTransformUtility.WorldToScreenPoint(null, corners[i]);
    }
     //Also Used but nothing changed
    //Texture2D ss = new Texture2D((int) (corners[3].x - corners[0].x), (int) (corners[1].y - corners[0].y),TextureFormat.RGB24, false);
    Texture2D ss = new Texture2D((int) (corners[3].x - corners[0].x), (int) (corners[1].y - corners[0].y));
    ss.ReadPixels(new Rect(corners[0].x, corners[0].y, corners[3].x - corners[0].x, corners[1].y - corners[0].y), 0,
        0);
    ss.Apply();

    string filePath = Path.Combine(Application.temporaryCachePath, "shared img.png"); //temporaryCachePath
    File.WriteAllBytes(filePath, ss.EncodeToPNG());

    // To avoid memory leaks
    Destroy(ss);

    new NativeShare().AddFile(filePath)
        .SetText("Can you beat my score?")
        .SetUrl(url)
        .SetCallback((result, shareTarget) =>
        {
            shareResult = true;
        })
        .Share();
    yield return new WaitUntil(() => shareResult);

Platform specs

Please provide the following info if this is a Unity 3D repository.

  • Unity version: Unity 2020.3.17f
  • Platform: IOS
  • Device: Iphone 13 Pro Max, Iphone X
  • How did you download the plugin: Asset Store
@karadot karadot added the bug label May 27, 2022
@yasirkula
Copy link
Owner

yasirkula commented May 27, 2022

Can you assign the texture (ss) to a RawImage to verify that the problem doesn't originate from the Texture itself? Can you also put a Debug.Log inside SetCallback and verify that it isn't called? Can you also check for any error logs?

@karadot
Copy link
Author

karadot commented May 27, 2022

I can verify SetCallback not working because I set shareResult in it, and wait it for it to became true. I tried app on IPhone SE, it worked correctly. I will assign texture to RawImage when I return to working on project, and let you know.

@yasirkula
Copy link
Owner

Thank you. Regardless, please add a Debug.Log to SetCallback, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants