IOS (IPad) How to load a screenshot created at runtime into a Texture or Texture2D

Hi. We are facing an issue with Unity. We are
developing an IPAD app. One feature is to take a screenshot and use it for
a button. Everything works fine on the MAC, but because the tree directory
in the IPAD where it doesn’t exist a Resources folder, we can’t use
“Resources.Load”. We have tried several solutions, like creating in the
IPAD a Resources folder (inside the Documents folder) and trying to load
the texture from it, or even this piece of code:

    public Texture LoadTextureFromFile(string filename)
    {
        Texture2D texture = new Texture2D(1024, 768);
        FileStream fs = new FileStream(filename, FileMode.Open,
FileAccess.Read);

        byte[] imageData = new byte[fs.Length];
        fs.Read(imageData, 0, (int)fs.Length);
        texture.LoadImage(imageData);
        return (texture as Texture);
    }

Any help would be greatly appreciated. We’ve been stuck with this issue for
several days

2 Answers

2

Perhaps you could load it with WWW.texture?
Or if you just want to grab the screen, use Texture2D.ReadPixels.

Hi. Yes, finally we got the texture to be loaded using the class WWWW. Thanks for everything

Please share your code? I'm having the same issue