c# - How to set Texture2D layer order -


i have timer draw screen texture2d rendered atop rect. problem can't figure out how let other elements on screen appear on or under it. currently, it's drawn on top of absolutely need menu appear on it.

hopefully not missing relevant info. had delete ton of code involves timer filling , other elements of scene.

using unityengine; using system.collections; using system; using unityengine.ui;  public class timer : monobehaviour {      public float timerwidth; // x coordinate timers' placement.     public float timerheight; // y coordinate timer's placement.     rect timebarrect; // bar coordinates.     rect blankbarrect; // blank bar coordinates.     texture2d timetexture; // color of bar when filling.     texture2d blankbartexture; // bar has yet filled.      void start (){          timerheight = 1.528f;         timerwidth = 4.54f;          cam = (gameobject.findwithtag("maincamera").getcomponent<camera>()) camera;          blankbarrect = new rect(0, 0, screen.width / 3, screen.height / 50);         timebarrect = new rect(0, 0, screen.width / 3, screen.height / 50);                   timetexture = new texture2d (1, 1);         timetexture.setpixel(0,0, color.green);         timetexture.apply();          blankbartexture = new texture2d (1, 1);         blankbartexture.setpixel(0,0, color.black);         blankbartexture.apply();     }      void update ()     {          timebarrect.x = cam.pixelwidth / timerwidth;         timebarrect.y = cam.pixelheight / timerheight;          blankbarrect.x = cam.pixelwidth / timerwidth;         blankbarrect.y = cam.pixelheight / timerheight;     }      void ongui(){           blankbarrect.width = (screen.width * .1f);          gui.drawtexture (blankbarrect, blankbartexture);          timebarrect.width = ((screen.width * .1f));          gui.drawtexture (timebarrect, timetexture);         }     } 

delete this:

void ongui(){      blankbarrect.width = (screen.width * .1f);      gui.drawtexture (blankbarrect, blankbartexture);      timebarrect.width = ((screen.width * .1f));      gui.drawtexture (timebarrect, timetexture); } 

and make rawimage gameobject in scene hierarchy under canvas

http://docs.unity3d.com/manual/script-rawimage.html

you can use findwithtag() , getcomponent<rawimage>() component , set texture property own texture

http://docs.unity3d.com/scriptreference/ui.rawimage.html


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -