Simple Saving and Loading with JSON to a File (Unity Save System Tutorial for Beginners)

preview_player
Показать описание
👍 Learn to make awesome games step-by-step from start to finish.
Let's learn Saving and Loading in Unity by using JSON as our file format and saving it into a File.

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#unity3d #tutorial #unity2d

--------------------------------------------------------------------

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

--------------------------------------------------------------------

Рекомендации по теме
Комментарии
Автор

🌐 Have you found the videos Helpful and Valuable?

CodeMonkeyUnity
Автор

i totally forgot about this i cant believe how easy it is, thank u.
i think i need to watch more videos about this topic

ggre
Автор

Your tutorials are so effective, well explained and, most importantly, straight to the point! No annoying waffle!
I've studied programming for 5 or so years now and have just picked up Unity, and you are helping me so much!
Keep it up :)

petermarsh
Автор

I have a computer science degree but I'm not ashamed to say that I still enjoy and benefit from watching your coding videos as they are so very practical and stress the importance of clean and reusable code!

GlobusTheGreat
Автор

Thank you for this!

Also if anyone wants the save file to not have the "_" on the first save time but have it if the save exists. For example it will save the first file as "save.txt" then any save after will be "save_1.txt", "save_2.txt", "save_3.txt" and so on Just use the following code as the Save function.

public static void Save(string saveString)
{
string theFirstSavePath = Path.Combine(Application.dataPath, "Save Folder", "save.txt");
string theFollowingSavesPath = Path.Combine(Application.dataPath, "Save Folder", "save_" + saveNumber + ".txt"));
int saveNumber = 1;
if ||
{
while (theFollowingSavesPath)
{
saveNumber++;
}
File.WriteAllText(theFollowingSavesPath), saveString);
}
else
{
File.WriteAllText(theFirstSavePath), saveString);
}
}

relentingVids
Автор

Very nice tutorial, I'm glad you made one on this topic

alexandrugd
Автор

it's giving me an "Object reference not set to instance of an object" whenever I try to use any of the IUnit methods (and yes I do have something set for Unit)

bigbangpegasusmaster
Автор

Hi, I don't know why but it never create a file, it can create a folder but it is always empty. I'm compiling for android, i don't know if that is what is causing the problems.

manuelillanes
Автор

Its so good but hard






Thanks

unvisibleone
Автор

Cool tutorial very helpful. i was going to use binary but binary is unsafe when deserializing so yeah!

Sandflowgames
Автор

if i import the utilities and this project unity say missing prefab and i have a black background

herzogtwo
Автор

That's why he is the GOAT, THE GOAT

yasserahmed
Автор

The type or namespace name 'IUnit' could not be found (are you missing a using directive or an assembly reference?) Help me pls

blablu
Автор

How would you extend this to more than just one object? I'm planning a city building game and I need to load the assets that the player placed where they were placed

DanielAbeleira
Автор

How would you go about serializing sprites? Right now, when i save the sprite it writes an instance id for the sprite, but when i load it again it returns null. Thanks in advance

icyicecream
Автор

If I used json file as database to store something like player information(like player's name, level), and publish as apk 1.0.
After a moment, I had updated and added certain new information(now it have player's name, level, stat and win/lose records) to the same json file and publish as new apk 1.1,
Will the previous player information (name and level) lost and replaced by new and clean json file?
Or how should we remain the old data while we updating json files?

chinyonglim
Автор

hi, why do you use a constant in your save system ? what's the point of doing that ?

ohj
Автор

I have watched, and read several videos/tutorials on the Save and Load function, but they all discussed binaries as the primary mechanism, why would I want a JSON over Binaries or vice versa?

SaSeshen
Автор

What object is meant to be assigned to the 'Unit Game Object'?

The_Peprechaun
Автор

Referencing from your Inventory video, Do I write the item.itemtype and item.amount into the SaveObject class? I'm trying to save the amount of the items that correspond to the itemtype. Pretty stuck on this for days trying to figure out how to accomplish this! Please help!

alecson