Here’s everything you need to know about saving game data in Unity!
► Go to , to take back your Internet
privacy TODAY and find out how you can get 3 months free.

● Easy Save:

♥ Support Brackeys on Patreon:


♥ Subscribe:

● Website:
● Facebook:
● Twitter:
● Instagram:


► All content by Brackeys is 100% free. We believe that education should be available for everyone. Any support is truly appreciated so we can keep on making the content free of charge.


♪ “ES_Dress Code_Black – oomiee” by Epidemic Sound


Xem thêm bài viết khác:


  • I just started to watch the video but I'll say this right now. If you just explain how to write data to disk without going into the actual problem of the save-game system which is about storing persistent references between objects created at runtime, I'll just hit the dislike button.

    Posted June 15, 2020
  • can any data type go into the files, or can it only be rudimentary data types? I am wondering if a float3[] may work.

    Posted June 15, 2020
  • Can you send the project link please

    Rajesh Sharma
    Posted June 15, 2020
  • Awesome video! It’s a great help for me. When I test it on Editor it works fine, but when I deploy on Android it doesn’t seems to save my file. I tried path.combine and it still doesn’t work. Does anyone has same problem and find a solution? I’m changing between multiple scenes, will this cause any problems?

    Chen Amber
    Posted June 15, 2020
  • Would this work on mobile games as well as webgl for build?

    Andrew Zi Zhen
    Posted June 15, 2020
  • If I build a game in WebGL would this work? Sorry in advance. Im pretty new at this.

    Sharan Uday Kumar
    Posted June 15, 2020
  • thank you <3

    Ahmad Deab
    Posted June 15, 2020
  • Thanks for this bangar tutorial 🙂

    Posted June 15, 2020
  • Please make a video on gta like save and load system please……

    Rp Freak
    Posted June 15, 2020
  • Does this work with consoles?

    UltraGamerPro 6
    Posted June 15, 2020
  • Can you save the names of the gameobjects in the scene;

    Srujan Kale
    Posted June 15, 2020
  • Someone can help me with Microsoft Visual Studio not showing the little minus sign button used wrap code ?

    Numero7 Mojeangering
    Posted June 15, 2020
  • I'm testing and working on 3D puzzle escape horror game And i just realise how complex have to be saving system to save all of the states of objects.. from player status to eveyfucking light sources on map destroyed while playing..
    Do you guys have any solutions that might help If i wanna save status of all objects in map/scenes? It has to be a way instead of writing tons of code for saving every object on the map..

    Posted June 15, 2020
  • Thanks a lot for this tutorial but I have an issue I want to save data for each level. I know that I can use an array to do so but have no idea how to implement it.
    Please help

    Amrit Patel
    Posted June 15, 2020
  • I got a question. How would i store a gameobject and load it?

    Manu Pfeil
    Posted June 15, 2020
  • How do I use this to save unlocked abilities

    Posted June 15, 2020
  • Covid has completely crippled my country's internet access. I can't see anything.

    Tubert Morti
    Posted June 15, 2020
  • The PlayerData class can be done WAY better.
    Make it a PUBLIC NESTED class WITHIN the Player class. That way your constructor can access the root class' (private) variables and thus you don't need to pass in those variables when instantiating the data class, which can be especially annoying with real world classes that hold 20 to 100 values.
    Furthermore, you can generically call such nested classes "Data". So…:
    new Player.Data().Save();
    Way more elegant, especially since you don't need to create to seperate scripts.

    Posted June 15, 2020
  • If you're going to use the BinaryFormatter, be aware that it's very difficult to recover data from a file if the code no longer matches the class that what was saved. BinaryFormatter needs to put a lot of wrapping around the serialized fields to recover them correctly, so you can't just open your save game in an hex editor and expect your old data to lay in raw binary form, it will be all scrambled.

    Also, um… always use a "using" scope instead of closing your streams manually, this will ensure that the file is closed no matter how the function exits. Your stream will not be closed if the serializer throws an exception, which is very likely to happen due to the issue above. It also won't be closed if later you add an early return later on.

    Lorem Ipsum
    Posted June 15, 2020
  • Well I just get a serializationException and after clicking 3 more times a IOException :l

    Z.R. Cai
    Posted June 15, 2020
  • how can i do the same thing with player rotation?

    Posted June 15, 2020
  • Can i save data with other simple datatype like uint and byte?

    Sky Lai
    Posted June 15, 2020
  • so, you are telling me I spent an hour making this, then tells me I can do it with an asset. Simple as that. Really?
    Well I already got it working. Im not doing anything more.

    Posted June 15, 2020
  • Hi. Can this be modified to work with images, or is there a better way to do it?

    Colin Bielby
    Posted June 15, 2020
  • Thanks Bro It Really Worked well and by the way i am a pretty big fan of you

    Kabir Random Entertaiment
    Posted June 15, 2020
  • You did it in 3 steps , the middle step is totally pointless. Lets review: firs your created a mono code inside the player that register things [level, health, position]. OK great, after that, you created a separated class called player that will take the variable from the mono behavior that is inside the player, then created another class that transform this class into binary file when you click SAVE. ok , when you click load , you take the binary file then you put it inside the player directly,,,,, HOLD ON WAIT A SECOND, what was the purpose of the second step? which is the class that is called player !!!!. couldn't you simply just take the data from the mono and store it as binary? would it be easier to load and save afterward ?

    Ibrahim Altaha
    Posted June 15, 2020
  • How do i find the path of the actual file made? anyone know?

    Json ZU
    Posted June 15, 2020
  • Here comes the savior of GameDev's community

    Harsch Shivam
    Posted June 15, 2020
  • how can we do this in android =)
    is this possible in android

    Map Crew
    Posted June 15, 2020
  • binary files can still be easily tinkered with especially if everything is nicely in order as this seems to be… Aren't better encryption algorithms used?

    Posted June 15, 2020
  • it's not working and give debug Error not found witch is debug error from code what's wrong

    Ahmad Gamal
    Posted June 15, 2020
  • Me over here using this for player, world, and item data. But I'd use Json for nodded items

    Its TTSI
    Posted June 15, 2020
  • 17:46 see dat first

    Lunar Age Studios
    Posted June 15, 2020
  • If the game crashes on android, will that trigger the OnApplicationQuit() function?

    Phasm Studios
    Posted June 15, 2020
  • BTW if you want to delete a file use file.delete (path)

    Its TTSI
    Posted June 15, 2020
  • this guide saved probably many days of my life keep it up!

    Posted June 15, 2020
  • hello sir i got problem
    when i write this code there is no error but when actually use this code and hit save button then there are
    two error shows
    1. safe file not found
    2. null reference Exception

    please sir help me to solve this error

    priyank bhikadiya
    Posted June 15, 2020
  • 9:43, Did you say ANY file type?! >:))))

    Posted June 15, 2020
  • This actually worked. This is amazing! Thanks so much! 100/10 would recommend and watch again.

    Double Pickaxe
    Posted June 15, 2020
  • Thank you man.. You are awesome!!

    omo loai
    Posted June 15, 2020
  • Is it just me whose going to use an entire array of paths and other thing?

    Its TTSI
    Posted June 15, 2020

Leave a comment