- Home /
Change a prefab's sprite in all scenes?
I'm having some trouble right now with my player sprite. I have a little shop inside my game where you can change the skin of the player, i've used a sprite changer script:
public class SpriteChanger : MonoBehaviour
{
SpriteRenderer spriteRenderer;
// Use this for initialization
void Start()
{
spriteRenderer = GetComponent<SpriteRenderer>();
}
public void change(Sprite differentSprite)
{
spriteRenderer.sprite = differentSprite;
}
}
It works fine inside the shop, but when i change from my Shop Scene to my Game Scene (i have a back to menu button, then a play button) It is not saved, even though I'm using the same player prefab on both the shop and the game scene. What do you think is the problem? I haven't really seen any tutorial addressing this error.
Are you marking your player object to not be destroyed upon level loading?
Answer by kidmosey · Sep 25, 2016 at 01:11 PM
Check out the unity tutorial: Persistence - Saving and Loading Data
Answer by mohammadawwad · Apr 16, 2020 at 01:18 AM
@Phantasmeow I am having the same problem where my player changes its sprite in the shop but does not get saved when i go back to my game scene Have you figured away to get around this problem or fix it by any chance