- Home /
Design/discussion question
Drawing Sprite from Script
I want to make a 2D strategy game. The map will consist of square tiles which I want to store in a 2D array of integers, for example, value 0 would represent a water tile, value 1 would represent a plain, and so on. I was wondering if there is any way to draw the sprites from a script. For example, determining the position by providing the top-left coordinates, the width, the height and the sprite itself. That way I would get rid of the gameobjects and I would just have to store a single sprite for each type of terrain.
I have been searching for it but I am unable to find what I am looking for, most results are about how to change the sprite rather than drawing it.
I am looking to do it this way since I have some code I did in Processing which works like that. Other reason is I want to be able to move the camera around, and this way I could do it just by changing the top-left position of every image.
My question is which is the easiest way to achieve what I want, if any.
Thank you.
We ask that design/discussion questions be asked on Unity Forums. I suggest you backup and research a bit more. Search out material on 'voxels' and posts on Unity Answers and Unity Forums on '$$anonymous$$inecraft'. In addition you might take a look at the following answer for some starter code:
http://answers.unity3d.com/questions/769358/tile-game-slow-lots-of-sprites-texture-atlas.html
Follow this Question
Related Questions
Draw 2d map array with SetTile or Instantiate ? 0 Answers
Tile/Slice a 3D Terrain Map 3 Answers
Quality Reduction only reduces my player sprite quality 0 Answers
Projecting a grid over a mesh 1 Answer
Get quads from mesh? [SOLVED] 0 Answers