Tile and offset a Texture2D?

I have a sprite sheet with a bunch of different items I want to use similar to minecraft’s. I need to tile and offset my sprite sheet so I can get each one of these items in the texture. The problem is that I need to do this for a Texture2D but I don’t think that’s possible because you can’t tile or offset a texture represented as a Texture2D. So my question is how do I get around this problem, how do I tile and offset a texture that can be applied to a GUI for a HUD?

Thanks.

I know how. I have this code that might come in handy:

var texture : Texture2D;
var scaleX : float = 1.0;
var scaleY : float = 1.0;
var offsetX : float = 0;
var offsetY : float = 0;

function Start() {
	// Create a new texture and assign it to the renderer's material
	renderer.material.mainTexture = texture;

    //Set the texture to the indicated offset
        renderer.material.mainTextureOffset = Vector2 (offsetX, offsetY);

    //Change the scale of the texture
	renderer.material.mainTextureScale = Vector2 (scaleX,scaleY);
}

I hope it helps you as well as it helped me out :smiley:

It is not possible to do either tiling or subtexturing (picking a region out of a larger texture) using UnityGUI. If you really need this, consider using a 3rd party GUI system, or make your own using textured quads aligned to a camera. Then you will be able to access either the material (as suggested in IllogicalIronical’s answer) or the UVs of the quad in order to do subtexturing.