- Home /
Sprite tiling and offset?
Hi, I started making a 2d game today, one thing that I couln't find is that in the sprite renderer component I don't see any tiling/offset variables, is it impossible to change because I need to do it and can't find a solution :/.
Sorry but when you answered I already had make it in a different way (Using 3d objects)
Answer by supernat · Dec 20, 2013 at 07:07 AM
Use renderer.sharedMaterial.SetTextureOffset(), or use renderer.material.SetTextureOffset() to change it for only one instance of the object. However, that could have serious implications to frame rate if you change a lot of them.
Answer by Athineku · Dec 20, 2013 at 02:09 PM
You can find an example (where the sprite is even animated) in unify wiki: http://wiki.unity3d.com/index.php/Animating_Tiled_texture_-_Extended . Note that I would recommend using Material.mainTextureOffset ( http://docs.unity3d.com/Documentation/ScriptReference/Material-mainTextureOffset.html ) instead of Material.SetTextureOffset and Material.mainTextureScale ( http://docs.unity3d.com/Documentation/ScriptReference/Material-mainTextureScale.html ) instead of Material.SetTextureScale.
Note: I never worked with this yet, this is only from what I remember from my Unity studies...
i'm using mainTextureOffset and the top and left of the texture image just stretch, it does not wrap around the plane. is there anyway to actually tile a texture onto a plane and animate the offset?
Answer by Simonius Skjorn · Aug 12, 2014 at 10:12 PM
Hi, I've made an asset that will solve exactly this problem: https://www.assetstore.unity3d.com/en/#!/content/20333
You can use any material with this and it's fairly efficient.