- Home /
Can I change texture tiling from w/in a script?
I want to have the parameters of my texture driven by outside variables. Is there a way of doing this?
Answer by CJCurrie · Oct 29, 2010 at 07:19 AM
Though it's not called Texture.tiling or Material.mainTextureTiling (as you'd think it should be), the correct method is here: http://unity3d.com/support/documentation/ScriptReference/Material-mainTextureScale.html
It's as easy as
renderer.material.mainTextureScale = new Vector2 (x, y);
Answer by Bampf · Aug 19, 2010 at 05:13 PM
Yes. In this case, what you are changing isn't the texture itself (although there are plenty of changes scripts can make to textures.) What you are changing is how the texture is applied, through a Material.
You can see this clearly in the editor- the texture scale and offset values are on the material component that is using the texture.
See the documentation page on Materials for how to do it. There are properties for the scale and offset of the main texture. For materials with more than one texture, there are methods for getting and setting scale and offset of other textures.
Answer by the_scholar · Jul 30, 2012 at 08:21 PM
Thanks for the answer everyone, I've been looking for this 'tiling' variable like a mad too (haha). The Unity staff member should maintain a better naming convention between the editor and the built-in classes :D
Yeah they should, this is a mess, NOBODY USES TER$$anonymous$$ SCALE WHEN TAL$$anonymous$$ING ABOUT TILING NO BO DY.