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: Auto tile texture - Questions & Answers - Unity Discussions
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.

1 Answer

1

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?

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