How to make a Save & Load System in Unity

How to make a Save & Load System in Unity

225.638 Lượt nghe
How to make a Save & Load System in Unity
In this video, I show how to make a Save and Load system in Unity that will work for any type of game. We'll save the data to a file in both a JSON format as well as an encrypted format which we'll be able to toggle between in the Unity inspector. *IMPORTANT:* For WebGL games, because WebGL can't save directly to a file system, a different method of storage than we use in the video needs to be implemented. See the pinned comment for more info on this. *IMPORTANT:* Some have mentioned having trouble with Unity versions prior to 2020. I'm not sure on the details, but if you're having issues with the serialization parts of this tutorial, upgrading your Unity version (to 2020 or higher) is something worth trying! Thank you for watching and I hope the video was helpful! 🙂 ► FAQ: I have some of the more frequently asked questions and important information regarding this tutorial in the Pinned Comment; however, more up to date/detailed FAQ's can be found on my Discord server. ► SAVE & LOAD SYSTEM TUTORIAL PLAYLIST The full Save & Load System tutorial playlist that this video is part of can be found here. https://www.youtube.com/watch?v=aUi9aijvpgs&list=PL3viUl9h9k7-tMGkSApPdu4hlUBagKial ► TIMESTAMPS 0:00 Intro 0:35 Save & Load System Design 3:25 Creating initial Game Data 4:26 Stubbing out the Core of the System 6:11 When to Save and Load 6:47 Passing Data to other Scripts 10:14 Reading and Writing to a File 16:10 Adding more Data to be Saved 17:15 Saving Collectables in a Dictionary 20:16 Serializing a Dictionary to JSON 23:00 Encrypting the Data 26:11 Outro ► RESOURCES Application.PersistentDataPath documentation https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html ISerializationCallbackReceiver documentation https://docs.unity3d.com/ScriptReference/ISerializationCallbackReceiver.html NewtonSoft JSON.NET for Unity - which can be used as an alternative to the method shown in this tutorial for serializing more complex data types to JSON. It can be installed through the package manager. https://docs.unity3d.com/Packages/[email protected]/manual/index.html ► GITHUB PROJECT The '1-starting-point' branch is the starting point of the project for this tutorial and the '2-save-load-implemented' branch is the end result. https://github.com/shapedbyrainstudios/save-load-system ► MUSIC The backing music is custom made by @themaykit. https://www.instagram.com/themaykit/ ► DISCORD Come ask questions, suggest a video topic, or just hang out! 📱Discord ➔ https://discord.gg/99gcnaHFf9 ► THE PATH OF REN Wishlist The Path of Ren on Steam! 🎮 Steam (The Path of Ren) ➔ https://store.steampowered.com/app/1619920 ► SOCIAL MEDIA LINKS 🐦 Twitter ➔ https://twitter.com/ShapedByRain 📷 Instagram ➔ https://instagram.com/ShapedByRainStudios 🕑 TikTok ➔ https://tiktok.com/@ShapedByRainStudios 🌐 Website ➔ https://ShapedByRainStudios.com ► SUPPORT Any support is much appreciated! I may receive a commission on any assets purchased using the below Unity Asset Store link. 🛍️ Unity Asset Store Affiliate Link ➔ https://assetstore.unity.com/?aid=1100lrxm5 ☕ Buy me a coffee! (Ko-fi) ➔ https://ko-fi.com/ShapedByRainStudios #gamedev #unity2d #unity