GUITexture created at runtime fills the whole screen

I am using the following code to create a GUITexture at runtime:

Texture2D tex = new Texture2D(1,1);
MapIcon.GetComponent<GUITexture>().texture = tex;
MapIcon.GetComponent<GUITexture>().color =;

It creates the texture correctly, with one exception. The texture is not of size 1x1. it is the size and shape of the viewport. Which is a problem as it covers up everything else in the application.

In futzing around with the GUITexture after it has been created, I have found that I can change its size (in the inspector) to negative values, it can be resized to about whatever I want, but I feel like i shouldn’t have to provide negative values to set the size of a GUITexture. It SHOULD take on the size of the texture it is given.


Try adjusting its Transform’s scale

using UnityEngine;
using System.Collections;
public class GUIController : MonoBehaviour {
public Texture2D yourtexture;
// Use this for initialization
void Start () {
// Update is called once per frame
void Update () {
void OnGUI()
GUI.DrawTexture(new Rect(10,10,60,60), yourtexture);