GUITexture created at runtime fills the whole screen

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

MapIcon.AddComponent("GUITexture");
Texture2D tex = new Texture2D(1,1);
tex.SetPixel(0,0,Color.blue);
MapIcon.GetComponent<GUITexture>().texture = tex;
MapIcon.GetComponent<GUITexture>().color = Color.blue;

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.

Thoughts?

Try adjusting its Transform’s scale

http://docs.unity3d.com/Documentation/ScriptReference/Transform-localScale.html

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);
}
}