Saving dynamic sprite is decreasing pivot

Discussion and help for Easy Save 3
Post Reply
robotSmith
Posts: 29
Joined: Thu Apr 01, 2021 4:53 pm

Saving dynamic sprite is decreasing pivot

Post 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!
Attachments
IssuePivot.mp4
Video with the issue
(1.42 MiB) Downloaded 23 times

User avatar
Joel
Moodkie Staff
Posts: 3785
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving dynamic sprite is decreasing pivot

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started

robotSmith
Posts: 29
Joined: Thu Apr 01, 2021 4:53 pm

Re: Saving dynamic sprite is decreasing pivot

Post by robotSmith »

Thanks for the reply Joel. Sent.

Post Reply