How to call Graphics.DrawTexture() in Update

How would you call Graphics.DrawTexture() from Update or any other function than GUI. I wanted to use Graphics.DrawTexture() instead of GUI.DrawTexture() just so I wouldn’t have to call it from OnGUI but it only draws a texture if its in OnGUI().

var texture : Texture2D;
var rect = Rect(0,0,0,0);
var color : Color;
var mat : Material;

function Update () {
//I would like to call Graphics.DrawTexture() here

function FixedUpdate () {
//Or maybe even here
function OnGUI () {
//But it only works here
   if (Event.current.type != EventType.Repaint){ //draws texture only in 3d space
      if(texture != null){ = transform.position;
         Graphics.DrawTexture(rect, texture, Rect(0,0,1,1), 0, 0, 0, 0, color, mat);

I don’t get any errors but it just doesn’t draw the texture when I call the function outside of OnGUI.

Thanks for any type of help.

Ok, since that other guy wont post his answer as an answer;

since I care that unity answers is a database for all users, not just my personal questionnaire;

AND since I know that most users who have the same question will click on this page, look at it for 2 seconds and see that there’s no official answer, then click off without really reading my question or the responses…

Answer Part:

OnRenderObject, if you want to call Graphics.DrawTexture() every frame you must call it from within OnPostRender().


This is because (I’m assuming) Graphics.DrawTexture() draws the texture immediately. Update() runs before the next frame is rendered.

Therefore if you call Graphics.DrawTexture() in the Update() function or any other function that is called before the frame is rendered, it will not show up.

That is why you have to call it in OnPostRender() (Called after frame is rendered) or OnGUI() (called multiple times a frame) or just after the frame has been rendered.

correct me if I’m wrong