So I drawn some tilemap and fill the entire game screen.
Now how to save this image as sprite and re-use it later at runtime when I need?
Unity doesn’t provide built-in function for this?
So I drawn some tilemap and fill the entire game screen.
Now how to save this image as sprite and re-use it later at runtime when I need?
Unity doesn’t provide built-in function for this?
RenderTexture can “photograph” anything you want in game.
After that, Texture2Ds can be .EncodeToPNG() or .EncodeToJPG() and written to disk.
Here’s all the parts and how I use them to snapshot the procedurally-generated levels in Jetpack Kurt:
So if I just need static image of edit-done-map, then I can just capture it with window capture software at maximum size of game screen and then use it as sprite image, right?
Another method I can think of that COULD work without a camera:
you can loop through your map and get the tiles at each position and then grab the asset for that tile type and get the sprite for that asset and then get the pixel data for that sprite. Then you copy that data to a large texture that has the dimensions of the whole map.
So the first tile in the upper left corner gets copied to the texture as a block in the upper left corner and so on.
Needs to be done for all layers of the tilemap of course.
And I am not sure right now if you can access the pixel data of a tile.