Custom editor - Texture turns white at certain width?

I’m making a custom editor which generates a texture from a wave-file and then displays it. I’m pretty sure the texture itself is fine, but when drawn, it turns white - but only at a certain width. Oddly, I never had this issue while working in an empty project. It only happens after I import it into some other project. I made it a package that I then imported using the package manager.

I tried using the texture as the background of a GUILayout.Box element, which gave the same result. At the moment, I am drawing it using raw OpenGL calls:

GUI.BeginClip(rect);
GL.PushMatrix();

GL.Clear(false, false, Color.black);

GL.Begin(GL.QUADS);

// Waveform
waveformMaterial.mainTexture = track.waveformTexture;
waveformMaterial.SetPass(0);
DrawTexturedQuad(xoff, 9, width, WAVEFORM_TEX_HEIGHT);

GL.End();

GL.PopMatrix();
GUI.EndClip();

void DrawTexturedQuad(float x, float y, float w, float h) {
            GL.Color(Color.white);
            GL.TexCoord2(1, 1);
            GL.Vertex3(x, y, 0);
            GL.TexCoord2(0, 1);
            GL.Vertex3(x + w, y, 0);
            GL.TexCoord2(0, 0);
            GL.Vertex3(x + w, y + h, 0);
            GL.TexCoord2(1, 0);
            GL.Vertex3(x, y + h, 0);
        }

Here are the material settings:

Does anyone know what might cause this issue?

1 Like

I’ve fixed it for now by lowering the texture width from 800 to 300. It seems that it only works if it doesn’t have to resize down more than to about x0.25 or so. I also tried generating a new material for each instance of the image, so I don’t have to change the texture out every frame - but this had no effect.