Page 1 of 1

Saving dynamic sprite is decreasing pivot

Posted: Wed Oct 20, 2021 5:27 am
by robotSmith
Hello!

I am having this weird issue where saving a dynamically created sprite decreases the pivot normalized value. How I'm doing the save is:
- Save the sprite
- Save the texture2d of the sprite
and on load:
- Load the texture2d of the sprite
- Load the sprite

This is the code snippet. I also attached a video showing the debug info on the Save and Load.

Code: Select all

   
    private void SaveDatabaseWithNewItems()
    {
        SaveSprites();
        ES3.Save<Dictionary<string, IItem>>("ItemDatabase", ItemDictionary);
    }

    private void SaveSprites()
    {
        foreach (string itemID in ItemDictionary.Keys)
        {
            if (ItemDictionary[itemID] is ItemAssembled)
            {
                string dictionaryID = itemID + "Sprite";
                ES3.Save<Sprite>(dictionaryID, ItemDictionary[itemID].Icon);
                string textureID = itemID + "Texture";
                ES3.Save<Texture2D>(textureID, ItemDictionary[itemID].Icon.texture);
            }
        }
    }

    private void Load()
    {
        ItemDictionary = ES3.Load<Dictionary<string, IItem>>("ItemDatabase");
        LoadSprites();
        ItemDictionary = ES3.Load<Dictionary<string, IItem>>("ItemDatabase");
    }

    private void LoadSprites()
    {
        foreach (string itemID in ItemDictionary.Keys)
        {
            if (ItemDictionary[itemID] is ItemAssembled)
            {
                string textureID = itemID + "Texture";
                ES3.Load<Texture2D>(textureID);
                string dictionaryID = itemID + "Sprite";
                ES3.Load<Sprite>(dictionaryID);
            }
        }
    }
 
Thank you!

Re: Saving dynamic sprite is decreasing pivot

Posted: Wed Oct 20, 2021 7:46 am
by Joel
Hi there,

Please could you replicate this in a new project containing only Easy Save, your Sprite and a simple scene/script, and private message it to me with instructions.

All the best,
Joel

Re: Saving dynamic sprite is decreasing pivot

Posted: Mon Oct 25, 2021 5:51 am
by robotSmith
Thanks for the reply Joel. Sent.