Texture2D works in editor, not in build

Howdy. I’m creating a new Texture2D in script and assigning it to an existing sprite as the sprite’s texture.

This works fine when playing the game in the editor, but when I build and run on PC, the texture shows as solid purple.
This particular purple - (255,0,255).

Any ideas on the problem?

Got it working. Had to use Sprite.Create() and and assign the Texture2D to it.