Why is Sprite.Create returning null?

In my game, I want my player to display one of two sprites.

  • //spr is a public Sprite variable
  • if (hasAltCostume) {
  • //this code will be replaced by something more complicated later
  • GetComponent ().sprite = Sprite.Create (spr.texture, spr.rect, spr.pivot);
  • } else {
  • GetComponent ().sprite = spr;
  • }

When hasAltCostume is false, the code works fine. When it’s true, the player is invisible - which I can only assume means the sprite is null.

What’s going on? Shouldn’t Sprite.Create(spr.texture, spr.rect, spr.pivot) just be a clone of spr?

Never mind, I figured it out.
spr.rect isn’t the “rect” Sprite.Create wants. That would be spr.textureRect.
And a similar situation with the pivot.