EVERYTHING you need to know to SAVE and LOAD your game in Unity

  Рет қаралды 7,750

Sasquatch B Studios

Sasquatch B Studios

Күн бұрын

Пікірлер: 23
@capilover1023
@capilover1023 3 ай бұрын
The consistency with which you make new content is enviable. Thanks for all the hard work you put into your videos - they've helped me grow as a developer and move from crappy games held together by duct tape and prayer to reliable scalable systems. I really like your code style and your neatness in general. It's rare to find such a thing on KZbin. It's obvious that you take pride in your craft. That's something to be respected. Good luck to you and your wife with your game!
@Putanothersockinit
@Putanothersockinit 2 ай бұрын
I am new to programming and slow with c# so I cant keep up with your speed yet, but many of your videos are topics that I am very interested in learning, and I like how you do programming, so thank you for putting these videos up! I subbed! I loved your video on loading scenes in the background! thank you thank you!
@rhushigulave3044
@rhushigulave3044 3 ай бұрын
Best video , i was looking or new save and load system for long time thanks 🔥 🔥
@midniteoilsoftware
@midniteoilsoftware 3 ай бұрын
Very nice Brandon. I'd like to see a follow-up video where you cover using Unity's Cloud Save to save game data in the cloud.
@HexedDev
@HexedDev 2 ай бұрын
Thank you very much for this tutorial. It helped me a ton with an issue I was trying to fix for 3 days !
@harneetsingh9420
@harneetsingh9420 3 ай бұрын
Many thanks for this video, liked even before watching. I am at work so will watch later when I get home thanks again :)
@vaibhavydarshan
@vaibhavydarshan Ай бұрын
i loved your tutorial, really helped me out!
@OrangeCat-vj4qx
@OrangeCat-vj4qx 2 ай бұрын
thankyou for this! it helped a lot i have a basic functioning save system i can add things to now. much better than wasting days and $100 on an asset
@HopperGameDevelopment
@HopperGameDevelopment 3 ай бұрын
Super, super useful. Thank you.
@fleity
@fleity 3 ай бұрын
Is there a way to serialize references to a certain scriptable object? Probably not, right? because the scriptable object instance gets newly instanciated and any Id that would point to it would be gone? Only way to do it I can think of is register a scriptable object instance with some manager class and on load set the reference to that new instance, similar as with the Enemy GameObjects? That is also the reason why you serialize the sceneID as string? (This looks pretty easy to break 😕)
@tymofeev.e
@tymofeev.e 2 ай бұрын
I also was thinking about that. And it would be much easier to use interfaces in save/load class.
@Briezar
@Briezar Ай бұрын
you can actually serialize ScriptableObject and MonoBehaviour (or practically any UnityEngine.Object) reference with JsonUtility; serializeable fields inside of them will serialize normally, while references to another Object will serialize as asset GUIDs. For example: public class MySO : ScriptableObject { public int number; public MyAnotherSO anotherSO; } will serialize as { "number": 0, "anotherSO": { "instanceID": 37792 } } Note that you cannot deserilalize it back by JsonUtility.FromJson, but you can *overwrite* or fill an existing Object's data with JsonUtility.FromJsonOverwrite, so you will do JsonUtility.FromJsonOverwrite(jsonSaveData, yourReferenceToMySO) and that MySO will now use the saved instanceID to fetch the asset and fill "anotherSO". It will only have its current data in the editor or whatever data is has when the game is built tho, you'll have to create another save data for that. But honestly I wouldn't advice serializing SOs, they should only be read-only data containers rather than a global variable that anyone can read and write to. FromJsonOverwrite will overwrite EVERY field so overwriting with an empty json will actually clear that SO's data in the editor, causing confusion and costing time.
@BarcelonaMove
@BarcelonaMove 2 ай бұрын
Is there a chance to have the source code for the example?
@Rezm0ni
@Rezm0ni 3 ай бұрын
Nice tutorial! Would be really cool if you could zoom a bit into the code itself. It’s really tiny as of right now when watching it on my iPad lol
@alissabrave424
@alissabrave424 2 ай бұрын
Is this work for webgl?
@dm1tryrin
@dm1tryrin 3 ай бұрын
Thank you Brandon! Very helpful video! Can you please tell me if there are plans to port Samurado for macOS ?
@yours_indie_game_dev
@yours_indie_game_dev 25 күн бұрын
is it possible to save gameobjects in json. or how are you saving the enemyprefab
@NorthernRealmJackal
@NorthernRealmJackal Күн бұрын
If you pause at 0:08 you can actually see the serialized "EnemyPrefab." It's simply a GUID pointing to the prefab asset, meaning that when you try to deserialize it, Unity looks for a GameObject with that GUID, and if it's a prefab already included in the game's assets, you can instantiate that. 25758 points to "FlyingMonkeyEnemy2.prefab", so that's what it'll deserialize to. That's why he stores the prefab instead of the instantiated GO: The instantiated GO will have a session-unique random GUID assigned upon creation, and when attempting a load, that GUID may point to something different, or might not exist.
@Mr-sy7lb
@Mr-sy7lb 2 ай бұрын
GameManager.Instance.Player.Save what is this part for i didnt get it
@unnamedsettler
@unnamedsettler Сағат бұрын
Anyone correct me if I'm wrong somewhere, but here's my understanding of it. I still consider myself fairly new to programming. Sorry for the wall, but hopefully this helps someone a bit. From his SaveSystem, he's calling for the Save() method within his "Player" class. GameManager.Instance is referring to the private instance of his GameManager class, which you can see set up at the top of the relevant script at 3:07. He's calling the capitalized "Instance" because it is a public getter for the main instance that is declared since it is private and can't be called normally: private static GameManager instance; public static GameManager Instance { get { #if UNITY_EDITOR if (!Application.isPlaying) { return null; } if (instance == null) { // Create new GameObject, apply component from "Resources" folder, and name the GameObject "GameManager" // This implies that GameManager needs to be kept in a folder called Resources somewhere within the project, typically in the Assets folder (Assets > Resources > GameManager script). Instantiate(Resources.Load("GameManager")); } #endif return instance; } } Everything between the two "#if" statements can technically be ignored, it's just ensuring that the GameManager is null when not in Unity's Play Mode, and creating a new GameManager if it is null upon entering Play Mode. Everything between #if UNITY_EDITOR and #endif is simply excluded from the final build. All of that is to say there should only ever be one GameManager active at any given time. Calling this from SaveSystem (or anywhere else) would be "GameManager.Instance" From there, he calls for the Player class, which is defined in GameManager (also at 3:07) as: public Player Player { get; set; } So now you have "GameManager.Instance.Player" And inside of Player class, he has his Save() and Load() methods, along with the public struct that holds the data to be saved/loaded from said methods. This then comes out as "GameManager.Instance.Player.Save()" He explains the "ref" keyword at 1:20, and why it's important to use it for saving. "_saveData" refers to the SaveSystem's own new SaveData(), and PlayerData (defined in SaveSystem's SaveData struct) refers to the PlayerSaveData struct that was created at the bottom of the Player class All of this ultimately comes out as the command to call the save method from the player class as: GameManager.Instance.Player.Save(ref _saveData.PlayerData);
@AgniKai-ht2bv
@AgniKai-ht2bv 3 ай бұрын
is this applicable for android?
@dm1tryrin
@dm1tryrin 3 ай бұрын
Yes. See the reference to PersistencePath - and otherwise everything else applies.
Handle UI Like a Commerical Game (with just ONE script) - Unity Tutorial
14:05
Creating a ragdoll in Unity
28:29
MitMac Games
Рет қаралды 28
SLIDE #shortssprintbrasil
0:31
Natan por Aí
Рет қаралды 49 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
How to Make a Main Menu in Unity
12:59
Damm Labs
Рет қаралды 80
Better Save/Load using Data Binding in Unity
18:47
git-amend
Рет қаралды 18 М.
How Video Game Economies are Designed
16:12
Game Maker's Toolkit
Рет қаралды 1,1 МЛН
SAVE & LOAD SYSTEM in Unity
18:20
Brackeys
Рет қаралды 1,1 МЛН
How to make a Save & Load System in Unity
26:56
Shaped by Rain Studios
Рет қаралды 208 М.
How to Start Gamedev in 2025
11:41
Sasquatch B Studios
Рет қаралды 3,5 М.
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 209 М.
CLEAN Game Architecture with ScriptableObjects | Unity Tutorial
13:12
Sasquatch B Studios
Рет қаралды 21 М.
Unity Code Optimization - Do you know them all?
15:49
Tarodev
Рет қаралды 201 М.