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()
{
DrawGUI();
}
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)
EDIT
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?
[10475-unity+2013-04-27+23-42-48-020.jpg|10475]][1]
[10476-unity+2013-04-27+23-42-50-376.jpg|10476]