#How are you supposed to deserialize

1 messages · Page 1 of 1 (latest)

indigo galleon
#

What stops you from just using [Serializable] ?

#

I guess - have you been able to serialize other things? Is there something that is making that functionality different with Scriptable Objects?

toxic basalt
#

It said I needed to CreateInstance

#

I just made a PlayerData class, which contains all the same data as PlayerInfo (the scriptableobject). But that also doesn't seem to work

#

oh maybe it does work. Hold on I'm still messing with it

visual hinge
#
Save Asset GUID: Instead of serializing the entire ScriptableObject, save its GUID.
Load Asset: Use AssetDatabase.LoadAssetAtPath to load the ScriptableObject using its GUID.``` is this relevant?
toxic basalt
#

I don't know. I'm still not sure why you can't use a scriptableobject for your save data

#

I'm running into issues because I switched from JsonUtility to newtonsoft json

#

Before I was using FromJsonOverwrite and that worked fine

visual hinge
#

i use Structs for my save-data soo i dont really know much I could tell ya when using SOs

toxic basalt
#

I can't get it to deserialize correctly. The json itself is correct, all t he values are right. But when I deserialize that into a class, it's all default

#
        foreach (var json in jsons)
        {
            print($"{json}");
            LevelCompletionInfo info = JsonConvert.DeserializeObject<LevelCompletionInfo>(json);```
#
    public LevelCompletionInfo(int id, bool heart, bool diamond, bool club, bool spade,
        int wins, int streakWins, int highScore)
    {
        Debug.Log($"creating levelcompletioninfo with id: {id}");
        levelID = id;
        heartAchieved = heart;
        diamondAchieved = diamond;
        spadeAchieved = spade;
        clubAchieved = club;
        totalWins = wins;
        winStreak = streakWins;
        highestAmountLeftover = highScore;
    }```
#

That's just a regular class, not SO

toxic basalt
#

omfg, I just needed to add a default constructor