Texture2D in OnGUI appears semi-transparent

I’m trying to use a pure black texture2D with varying alpha values to create a fade-in/fade-out effect for scenes. However, the black texture2D appears semi-transparent, even when its alpha is 1. What’s wrong?

private Texture2D blackTexture;
 
void Start () {
        blackTexture = new Texture2D (Screen.width, Screen.height);
}
 
void OnGUI() {
        GUI.depth = -1000;
        GUI.color = new Color(0, 0, 0, 1f);
        GUI.DrawTexture( new Rect(0, 0, Screen.width, Screen.height ), blackTexture );
}

you’re not setting the texture’s colour to anything… no idea what the default for a newly created texture is but try setting it to something you want.

Thank you! That was likely the problem.

I also found this example, where the poster creates a 1x1 pixel Texture2d, so there’s only 1 pixel that needs to be set to black. Using it that way, it works great!

Apparently there’s also a static Texture2D.blackTexture, but I couldn’t get it to work; I didn’t see anything when I attempted to draw it. No idea why.