hey guys how would i make one huge texture 2d map just 1 texture made of like randomly picked textures, so i got something like it but its not one texture this right here i will show is like 3,000+ so here is the image, if you guys know how to make this 3,000+ become one texture please tell me:
each one of those textures are 16x16 pixels. the map ingame is a 10x, 10y the textures are like 0.16x, 0.16y, 0.16z. if you guys need to know anything else just say so, well i would not be giving you the code for spawning those 3000+ textures beacuse they are not the same script as the one that i am trying to make a generation thing like it just that they will all be one texture, and i don’t mean like take a picture i mean like it generates as one texture instead of 3000+
Use a render camera.
in a new scene… create a camera, set it to ortho mode.
Hopefully your object is a whole unit size and square… If its not, fix it so it is.
Next make the camera Orthos size, match your object.
e.g. if your square is 10 unity units… then set your camera ortho size to 5 (radius) put your object in front of the camera so its facing the camera, (local position 0,0,10) and it should fill the screen exactly from left to right edge of the camera view (if you run the scene, or just click on th camera in scene view)
next, create a render texture somewhere in a project folder, and set the camera’s render target to be that texture… (drag the render texture onto the slot on the camera component for target) the camera will now start rendering its view to that texture… as 1 single texture…
If you need this at run-time. you can have the camera off, then just turn it on for 1 frame, or temporarily, and call Camera.Render() from a script.
If you need to save this out, then you’ll need to make an editor script on Ui Drop down, it should look for scene camera, do a render, look at the render target, grab that texture, and save the texture out as a file.
You can save out the texture like this…
Using System.IO;
File.WriteAllBytes(Application.persistentDataPath + "/" + texFileName, texReference.EncodePNG());
i fixed it myself guys, so this is not even close to be done but here should be a tile based generation like thing that is one texture that puts 16x16 textures on it: `public Texture2D texturelist;
public Texture2D sourceTex;
public int width = 160, height = 160;
void Start()
{
StartCoroutine(WorldGeneration());
}
IEnumerator WorldGeneration()
{
Texture2D destTex = new Texture2D(width, height);
for (int j = 0; j < width; j += 16)
{
for (int z = 0; z < height; z += 16)
{
int b = Random.Range(0, texturelist.Length);
sourceTex = texturelist**;**
for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { Color pix = sourceTex.GetPixel(x, y); destTex.SetPixel(j + x, z + y, pix); destTex.Apply(); Sprite destsprite = Sprite.Create(destTex, new Rect(0, 0, 160, 160), new Vector3(0f, 0f, 0f)); GetComponent().sprite = destsprite; if (x == 16) { y = 0; x = 0; break; } } } yield return new WaitForSeconds(0.01f); } } }` So the waitForSeconds can be changed guys if you want ok!!