DrawTextureWithTexCoords no errors but not displaying clipped texture

It only shows a semi transparent blue gui on the screen but no texture, anyone know how to solve this? Thanks

edit: hmm…anyway this is the script to atlas textures for GUI right?

edit: okay nvm, I think I’m using the wrong approach, solve this problem by using texture2D and set getpixels, Thanks anyways.

var tileTexture : Texture;
var tHeight:int=49;
var tSize:int=200;
var tileX:int=337;
var tileY:int=503;

function OnGUI () { 

GUI.DrawTextureWithTexCoords(
new Rect(new Rect(tileX,tileY, tHeight, tHeight)),
tileTexture,
new Rect(0,200,tSize, tSize));
}

Hi,

To use GUI.DrawTextureWithTexCoords,
you should check this : texCoords rect for GUI.DrawTextureWithTexCoords - Questions & Answers - Unity Discussions
Everything you need to know might be there…

(

The second Rect is for UV co-ordinates, IE. they go from 0 > 1
anything higher than 1 causes additional tiling (if the texture is set to repeat).

if you want to extract just a part of the texture, you need to know where it is in terms of UVs (try dividing the pixel co-ordinates by the width and height)