Is there a way to set an individual sprites tiling either via editor or through script?
I’m trying to create ladders of variable length (in units of 1 by X - so always in chunks of 1) and tile it accordingly.
I can do this currently using a Quad and mesh renderer and setting the tiling on the material instance via script, but was wondering if possible with the new sprites.
Well, the great thing about the sprite system is that if you place multiple copies of a sprite in the scene, it’s pretty much the same as just having repeating UV’s, as the same sprites are batched into a single draw call. So I’d say just place your pieces for however many you need.
If your Pixel ratio on your sprite settings is the default 100, then your sprite’s dimensions in units will be 100/pixels, if it’s a 32x32 sprite, then you want to move it by 0.32 unit’s. Just set your Editor Snap settings to 0.32 or 0.16 so you can get power of 2 snapping.
Not really, the sprites use a single set of coordinates to define the image it use. Someone had posted, (no idea if it is accurate) that they may add that ability. Personally, I don’t see the need it seems counter to idea behind sprites, but I guess more features are better than less.
But you can accomplish your goal in few ways off the top of my head:
Complex Way
Unless you want to scale it in real time, you could generate a new texture by programmatically combining images and using the new image to make a sprite. Alternately you could have one big ladder image and create a new sprite by cropping the image.
“9 slice”
Similar to how you construct a 9 sliced object, create 4 sprites (top, middle, bottom and crossbar) Based on height, inside a new container/gameobject, place your top and bottom then stretch the middle to meet the others. Then place as many crossbars as need along the height.
Simplest
Do exactly what you have been doing with quads. I mix quads/meshs with the 2d stuff all the time for certain needs. You can use “sortingLayerName” and “sortingLayerOrder” on the renderer to ensure they play well with everything else.
I wonder if i do it like this, using 1 sprite = 1 tile, cause any issues if you do use a large number of tiles.
I’ve just started my project and wanted to go with the use of differents sprite atlases (weapons, npcs, floors etc.). So im looking for a good solution to not stuck wit performance issues at the end.