Showing posts from July, 2016

Setting several textures as one texture biased off of a 2d array. aka how to use Texture2D.SetPixels().

When using a 2D grid based map system using the design within this tutorial it will help Unity only have to render one texture rather than several hundred. Hopefully this will teach you how to set individual textures into one texture.
Since I'm not going go into detail on how to create this map generation a great tutorial to learn how to set up grid based maps for your game can be found here. Some code from the tutorial can be used to help get you up and running, this is below, just copy paste in to Unity. It will create a 2d array of type int named wallMap and fills it with ones and zeros. Please note this only creates an outside 'wall'. This example works using Texture2D. This code was taken from Sebastian Lague, for more information on how to use it please see the tutorial mentioned above. public int width, height; public string seed; public bool useRandomSeed; [Range(40, 70)] public int randomFillPercent; [Range(0, 10)] public int smoother; …