is using OnPostRender to draw textures Pro only?

Im trying to draw a texture on screen using Graphics.DrawTexture, but I am getting no results. but if i were to use it in OnGUI it suddenly decides to draw the texture.

     void OnPostRender() 
      IEnumaertaor DrawGUI() {
      yeild return new WaitForEndOfFrame;
      Graphics.DrawTexture(new Rect(0,0,128,128),MyTexture);

this does nothing…its currently unknown to me why but…

        void OnGUI() 
        if (Event.current.type == EventType.repaint)
                 Graphics.DrawTexture(new Rect(0,0,128,128),MyTexture);

this does…works great infact, however it called many times a frame making it
a waste to use. I tried Google only finding unrelated answers,
tried adding the script to a camera, also tried removing the “if” block. can someone explain why is this happening? (or why unity needed to remove this from basic)

I’ve just realized my GUI was drawing but in the stupidest possible manner, it wasn’t drawing on screen but based on the coordinated of the Game_manager(which manages GUI and scene transition and other things). lol, i watched my scene view to see the giant 128x128(level units) texture floating behind the player lol. I have no clue on fixing this… would camera.WorldtoVeiwportPoint be a starter?


“OnPostRender is called after the camera renders all its objects. If you want to do something after all cameras and GUI is rendered, use WaitForEndOfFrame coroutine.”

Basically what could be happening is that something is getting drawn ontop of your texture for not using the WaitForEndOfFrame coroutine.

Putting event code in OnPostRender isn’t possible - it only works in OnGUI and functions it calls. OnPostRender is called to let you do stuff with a render texture - so isn’t much use on Free as you can’t get one.

Graphics.DrawTexture and GUI.DrawTexture both work in screen coordinates. So if you want the screen coordinates of a world object you use camera.WorldToScreenPoint.

i stumbled upon a solution to use Graphics.DrawTexture in PostRender randomly through testing.
simply put you need to setup Matrices to stop it from drawing in World space which only happens outside OnGUI, I’m not sure why that happens. Anyway here is how to fix it, some sample code:

        Graphics.DrawTexture ( new Rect (0,0,300,300), MyTexture, 2, 2, 2, 2, null);

this only works if its attached to the main camera or the camera with the upper depth. it also need to be redrawn after every frame. turns out it had nothing to do with co routines or using the wrong type of coordinates. whether this method is safe or not performance wise is to be determined.
hope it helps other users