- Home /
 
How to create gui from code ?
Hi,
I love unity ui but is there a library to quickly add gui from code ?
Thanks.
               Comment
              
 
               
              Answer by m0guz · Jun 07, 2018 at 07:58 PM
For testing/helper buttons for your scene, take a look at MonoBehaviour.OnGUI, it is great and easy to use.
Answer by toddisarockstar · Jun 08, 2018 at 01:06 AM
     public Texture2D TestImage;
     void Start () {
         // make a very small one pixel green image from code like this:
         TestImage = new Texture2D (1, 1);
         TestImage.SetPixel (0, 0, Color.green);
         TestImage.Apply ();
     }
     
     
     void OnGUI () {
 
         //you can display an image like this
         GUI.DrawTexture (new Rect (100, 100, 300, 300), TestImage);
         GUI.Label (new Rect (100, 100, 300, 300), "here is some text");
 
     
     }
 
              Your answer