Unity unloading needed assets at build

I have some code for a UI switch like this:

[SerializeField]
private Sprite _spriteOn;

[SerializeField]
private Sprite _spriteOff;

In the inspector I’ve dragged the appropriate sprites into these fields. The script simply places the sprite into an Image object based on a boolean value. It works fine when running from the editor. However, when I build to iOS, only the sprite that is in the Image object at build time will show. I suspect Unity is unloading the other sprite because it doesn’t think it’s being used. Any ideas how I can fix this?

Did you drag n drop the sprites onto this script, and this script is on a game object prefab (asset) or object in the scene?

In other words, you didn’t drag this onto the script itself in the inspector?

No prefab. Just a script that’s on an object in the scene. I dropped the sprites onto the fields in the script’s inspector. The object has an Image component attached that displays the sprites (initially set to one of them). It’s strange because it works totally fine when running from the editor.

Okay, but just to be absolutely sure, you mean the script when it’s on the game object in the scene… it’s to that you dragged the sprites?
I only ask, because you can drag ‘default’ references to scripts in the editor, but they only work in the editor.

Otherwise, I’m not sure how that would happen. That sounds very strange, indeed.