How do I fill a Texture2D with pixels and display a sprite with that texture using script?

Hi, I’m trying to make a little pixel transition a-la pokemon battle transition.
To do that I need to write pixels per frame to a Texture2D and then set the gameobject’s spriterenderer’s sprite.
My script creates a Texture2D as I want it, I can tell in the editor. But creating a Sprite from that doesn’t seem to work.

40227-8rvuq9.jpg

40226-4w97pn.jpg

	void Awake () {
		frame = new Texture2D(size, size);
		
		for (int x = 0; x < size; x++){
			for (int y = 0; y < size; y++){
				frame.SetPixel(x, y, color); 
			}
		}
		frame.Apply();
	sprit=new Sprite();
		sprit=Sprite.Create(frame, new Rect(0f,0f,size,size), new Vector2(0f,0f));
		gameObject.GetComponent<SpriteRenderer>().sprite=sprit;
	}

Solution: don’t be stupid and have the alpha set to 0