Problem saving object

Discussion and help for Easy Save 3
Post Reply
jinxology
Posts: 35
Joined: Sat Sep 13, 2014 5:21 pm

Problem saving object

Post by jinxology »

Hey there! I'm having a problem with an object (Character) not saving the any of the fields. The parent object's fields are saving correctly (Player) and I have the Character fields selected in the Types area for Character, but my save file looks like the data at the bottom of this post, with both currentCharacter and the List of Characters only showing ES3Ref. The structure of Player is below. I'm sure I'm doing something dumb because I've done this a million times. Any ideas?

Code: Select all

public class Player : MonoBehaviour
{
    private int gold;
    public Character currentCharacter;
    public List<Character> characterList; 
    public float sfxVolume; 
    public float musicVolume; 
    public float masterVolume; 
    public bool fullScreen; 
	*SNIP*
Here's the save file:

Code: Select all

{
	"dsc_profile0.sav" : {
		"__type" : "DungeonCrawlStars.Player,Assembly-CSharp",
		"value" : {
			"_ES3Ref" : "66787333034462070",
			"goID" : "2786608423426076912",
			"gold" : 0,
			"currentCharacter" : {
				"_ES3Ref" : "3745259361347740813"
			},
			"characterList" : [
				{
					"_ES3Ref" : "3745259361347740813"
				}
			],
			"sfxVolume" : 1,
			"musicVolume" : 1,
			"masterVolume" : 1,
			"fullScreen" : true
		}
	},
	"dsc_activeProfile.sav" : {
		"__type" : "int",
		"value" : 0
	}
}
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problem saving object

Post by Joel »

Hi there,

Fields of reference types are saved by reference. If you want to save them by value you would need to save them separately using a separate ES3.Save call. Alternatively you can create an ES3Type for the type containing the fields through the Types window and modify the Write calls of the fields to include the ES3.ReferenceMode.ByValue parameter.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
jinxology
Posts: 35
Joined: Sat Sep 13, 2014 5:21 pm

Re: Problem saving object

Post by jinxology »

Great, thanks Joel, I knew I was doing something silly!
Post Reply