Such a problem: from the script, I change the image of the sprite of SpriteRenderer component (like another skin) in a certain prefab, having a link to SpriteRenderer. And the problem is that when I run the game in unity, everything works, i.e. the skin changes. And when I run it in the app (apk file), the skin doesn't change. Why is that?

[SerializeField] SpriteRenderer player; // in the inspector, I drag the player's prefab to this field
[SerializeField] Sprite[] skins; // here I drag the player's images (skins)
int i = Random.Range(0, skins.Length);
player.sprite = skins[i]; // this is how I assign the skin to the player
  • \$\begingroup\$ When does this code run? Please try to give us enough setup instructions that we can reproduce this problem in a new empty project, so we can test potential solutions. \$\endgroup\$ – DMGregory May 18 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.