JsonSavingSystem Equipment Bug

Hey guys,
I encountered a bug with the Equipment, when for example i saved with an empty equipment inventory and then dragged for example a helmet into the helmet slot and pressed load, the helmet icon was still in the slot and as i tried to drag it to the inventory I got a nullpointer exception.

If someone else is also having this problem: I solved it by adding this line

equipmentUpdated?.Invoke();

to the end RestoreFromJToken Method of the Equipment.cs file.

1 Like

Yikes! I thought I got that patched in mytutorial. I’ll fix it tonight when I’m at my prodution computer.

1 Like

Am I reading the title of this post correctly?

I have not gotten started working in the RPG Inventory course yet, but are we using JavaScript Object Notation (JSON) in this course? :thinking:

If so, that is weird and unexpected, but cool.

We’re not. Through the course, we are using the BinaryFormatter, but Microsoft has deemed that unsafe (it’s perfectly fine while you’re working through the course, just don’t publish a game that sends save files over the interwebs with it)…

I’ve written an alternative saving system using Newtonsoft’s Json library. SavingSystem

1 Like

Wow, that’s really cool! Thank you for the response!

I remember seeing a post about a bug with the saving system and it being on hold for a while.

Is the json saving fixed/complete/patched?

Yes, it was put on hold because it originally used a set of extensions to Newtonsoft that allowed you to serialize Vector3, Quaternion, and other classes that couldn’t be serialized normally. Then we learned that games built with IL2CPP weren’t always linking reflection based code.

The new version avoids this by encoding all data structures manually.

1 Like

Wow that’s quite concerning. My game I’m working on is purely singleplayer… but if I was building an online system then I should opt for your JSON approach? That’s a pain in the butt.

It may seem daunting at first, but it has many advantages, not the least of which is being able to read the save file during testing. In production runs, using an encryption strategy, you’ll find you’re pretty safe from hacking as well.

3 Likes

Privacy & Terms