Hi,
I used the tutorial to below implement summary information in my own project.
https://www.pixelcrushers.com/phpbb/vie ... f=3&t=2594
Most of my envisioned system has been successfully implemented but I'm looking at two remaining tasks to do:
1 - Accessing the save system involves the use of a camera ingame that takes a picture of the player. This is not a screenshot, but a randomly selected sprite from a library unique to each scene. I think I am able to serialize it without any errors, but I can't seem to deserialise it and get a null reference.
2 - I also want to add the currently active main/story quest that the player is on. I am aware that I can add quests to groups so it would be a matter of finding the main quest group and looking for the quest which is active in there. Is there functionality to support this? In addition, due to the story the main quest line is not instantly started when the game begins but comes in potentially after the player has had the opportunity to access a couple of save points, so I believe I would need to return null or nothing if no quest are active.
Would you be able to shed any light on this? Thanks in advance.
Saving Sprites
Re: Saving Sprites
Hi,
The answer to both of these depends on how you want to catalog save slots. There are two ways to catalog them:
1. Embed this "meta" information in the saved game data itself (e.g., a save file if you're using DiskSavedGameDataStorer).
If you maintain a separate catalog, store the sprite name in the catalog file.
If you embed the info in the saved data data, write a Saver subclass that returns the sprite name. When showing the catalog of save slots on your load game screen, you'll need to use SaveSystem.storer.RetrieveSavedGameData(#) to get the SavedGameData for the slot. Then use SavedGameData.GetData(key) to get the sprite name from the Saver.
Then save it in your separate catalog or in a Saver subclass similarly to the info above for the picture.
The answer to both of these depends on how you want to catalog save slots. There are two ways to catalog them:
1. Embed this "meta" information in the saved game data itself (e.g., a save file if you're using DiskSavedGameDataStorer).
- Pro: Each saved game file is self-contained with its metadata.
- Con: To show the list of saved games, you must read and deserialize all of the saved game data, which might be slow if you have a lot of large save files.
- Pro: Faster to load when you want to show a menu of available saves.
- Con: A separate file to maintain.
If your game took a screenshot, it would be a little more complicated because you'd have to serialize the screenshot pixels. With your randomly-selected sprite, you can just store a reference to the sprite. To minimize the amount of images loaded into memory, I suggest using Unity's Addressables package. Tick each sprite's Addressable checkbox, and set its addressable key to the sprite's name. When you save it, save the sprite's name as a string, which is easy to serialize and deserialize. To load the sprite, deserialize the name and use the Addressables API to load the sprite.Mackerel_Sky wrote: ↑Sun Apr 04, 2021 6:10 am1 - Accessing the save system involves the use of a camera ingame that takes a picture of the player. This is not a screenshot, but a randomly selected sprite from a library unique to each scene. I think I am able to serialize it without any errors, but I can't seem to deserialise it and get a null reference.
If you maintain a separate catalog, store the sprite name in the catalog file.
If you embed the info in the saved data data, write a Saver subclass that returns the sprite name. When showing the catalog of save slots on your load game screen, you'll need to use SaveSystem.storer.RetrieveSavedGameData(#) to get the SavedGameData for the slot. Then use SavedGameData.GetData(key) to get the sprite name from the Saver.
Write a method to return the current main quest name. Example:Mackerel_Sky wrote: ↑Sun Apr 04, 2021 6:10 am2 - I also want to add the currently active main/story quest that the player is on. I am aware that I can add quests to groups so it would be a matter of finding the main quest group and looking for the quest which is active in there. Is there functionality to support this? In addition, due to the story the main quest line is not instantly started when the game begins but comes in potentially after the player has had the opportunity to access a couple of save points, so I believe I would need to return null or nothing if no quest are active.
Code: Select all
public string GetMainQuestName()
{
foreach (var quest in DialogueManager.masterDatabase.items)
{
if (quest.IsItem) continue;
if (quest.LookupValue("Group") == "Main") return quest.Name;
}
}
-
- Posts: 111
- Joined: Mon Apr 08, 2019 8:01 am
Re: Saving Sprites
Hi Tony,
Thanks for the tips. I have managed to implement the sprites using your advice, and will take a look at the quest stuff this week.
Hope you had a great Easter!
Thanks for the tips. I have managed to implement the sprites using your advice, and will take a look at the quest stuff this week.
Hope you had a great Easter!
Re: Saving Sprites
Happy to help! Glad you got the sprites working.