Hi, I am struggling with how, once I take a screengrab, how to apply it to a Texture2D.
I have looked at the www. and loadImage() but one requires a url and one an image. All I have is a path…“documents/pictures/screengrab”. How do I take this path and apply it return to a Texture2D?
Thank you
This would load an image into a Texture2D:
WWW www = new WWW("file://"+ Application.dataPath +"/filename.png");
Texture2D texture = new Texture2D(99, 99, TextureFormat.ARGB32, false);
www.LoadImageIntoTexture(texture);
“Application.dataPath” in the example is the absolute path to the game’s Assets folder. Can be replaced to a different folder on your computer (just keep in mind that it should work on other people’s computers as well so hardcoded paths outside the Assets folder is probably not a good idea).
1 Like