- Home /
Repeat texture instead of scaling
Hey. I'm not very knowledgable about textures so I apologize if this is very simple.
What I want is to have a plane with a tileable texture, and when I scale this plane for the texture to just repeat instead of scaling itself to fit the plane.
I want the same thing as was asked in this thread: http://answers.unity3d.com/questions/126206/auto-tile-texture.html But I don't understand how to use the answer given there, and I would also like the texture changes to be visible in the editor and not only at runtime.
Thanks for your time.
Answer by PedramAUS · Feb 03, 2013 at 08:38 AM
By using Material.mainTextureScale you can tweak tiling values.
transform.renderer.material.mainTextureScale = new Vector2(XScale , YScale );
That works very nicely, thanks. Is there any way to make that code run in the viewport as well as during the game so I can see the textures as they would appear while editing?
$$anonymous$$ay be I am too late for answering this but, by using
ExecuteInEdit$$anonymous$$ode you can execute this script in edit mode.
If you select the gameobject, the material component of the object has got the x and y tiling values that you can modify.
This changes tiling for all the objects with the same material, but no worries. It's fine if it only works at run time, I'll just have to get used to distorted textures in the view port :P