Hi, I'm creating a 1x1 semitransparent white texture and using it to fill a 100x100 rectangle. This is the code
public void Update()
{
Texture2D seltext = new Texture2D(1, 1, TextureFormat.ARGB32, false);
Color col = new Color(1, 1, 1, (float)0.2);
seltext.SetPixel(1, 1, col);
seltext.Apply();
GUI.DrawTexture(new Rect(100, 100, 100, 100), seltext);
}
but when i run the game i get NullReferenceException: Object reference not set to an instance of an object UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image, ScaleMode scaleMode, Boolean alphaBlend, Single imageAspect) UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image)
why?