Saving with Binary Serialization Made Easy [Unity Tutorial]

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024

ความคิดเห็น • 62

  • @sherlyhudson2198
    @sherlyhudson2198 3 ปีที่แล้ว +7

    This is what I needed! Thank you. However can you show or explain how you would save a list? For example, I want to save a list of characters who are in my party and they have stats like hp, mana etc.

  • @LuizFelipe-jb3uv
    @LuizFelipe-jb3uv 4 ปีที่แล้ว +2

    Your channel is very helpfull,theres few content on youtube about this part of development and you do a lot of stuff about it,thank you for producing it

  • @stevancosovic4706
    @stevancosovic4706 11 หลายเดือนก่อน

    Better and safer than JSON saving, loading, thanks!

  • @jakubkorczynski9370
    @jakubkorczynski9370 2 ปีที่แล้ว

    I don't get why your film isn't first in search, better knowledge and way more modular. I watch it once and i already have idea how can i implement it after some modification in my game. more "how to" films shows they way to save, made on specific subject, which need to get more info about they sampled project, here i get info how it works and how i can use it without spending time on getting in to creators way of thinking. great job!

  • @JTAGames
    @JTAGames 4 ปีที่แล้ว +1

    I will happily be implementing this tomorrow thanks to you my friend 🤙

  • @Gsiniguez
    @Gsiniguez 4 ปีที่แล้ว +1

    Amazing channel! Subscribed :D

  • @ThePancakeJedi
    @ThePancakeJedi 2 ปีที่แล้ว

    Said it before, said it again: excellent tutorial!

  • @lunner505
    @lunner505 2 ปีที่แล้ว

    Perfect Im gonna suscribe to this channel

  • @Hozgen
    @Hozgen ปีที่แล้ว

    this bro helped me a lot, thank you!

  • @iunholy
    @iunholy 3 ปีที่แล้ว +1

    Sorry for asking again but, I am interested of 9:50 how to create a new save object right there where we have return null; ?

  • @versystudio822
    @versystudio822 3 ปีที่แล้ว

    Thank you for the great & clear video!

  • @benjaminlehmann
    @benjaminlehmann 2 ปีที่แล้ว

    So great. Thank you for the learning.

  • @tomkiptom
    @tomkiptom 3 ปีที่แล้ว

    awesome thank you finally a clear tutorial :)!

  • @ivannavarromartinez8418
    @ivannavarromartinez8418 3 ปีที่แล้ว +1

    I have a problem. When I add ""public SaveObject so;"" on TestObject it gives me an error like it can't be recognized... Some idea? Thanks for the tutorial.

  • @tensaigamer7283
    @tensaigamer7283 4 ปีที่แล้ว +1

    How to delete game data in Binary

  • @entertainmentoverloaded5700
    @entertainmentoverloaded5700 2 ปีที่แล้ว

    U saved my life again :D

  • @RandomCoelho
    @RandomCoelho 3 ปีที่แล้ว

    Thank you so much !

  • @dennisgonzales9521
    @dennisgonzales9521 4 ปีที่แล้ว

    Awesome!

  • @donjohnson4347
    @donjohnson4347 3 ปีที่แล้ว

    I try the code but I got unauthorized access exception: error

  • @donjohnson4347
    @donjohnson4347 3 ปีที่แล้ว

    How would you generate a backup just in case the original file get corrupted

  • @sapphiretigress1
    @sapphiretigress1 3 ปีที่แล้ว

    i'm still stuck on this but I'm keeping at it. I feel like your video is much easier to follow than Brackeys as he names all of his variables the same damn thing -__-
    I am laughing hard at the auto generated closed captions though XD "the freeze will create one more private static poo directory" hahaha

    • @comp3interactive
      @comp3interactive  3 ปีที่แล้ว +1

      Yeah man, keep practicing! No one gets it first time over
      Brackeys is 100% a great source. I learned a lot from him myself but there are a few flaws imo
      And yeah, I've seen a few of the captions it generates for me, TH-cam must really have a hard time with my accent 😂
      Keep up the good work my dude, you'll be a pro in no time!

    • @sapphiretigress1
      @sapphiretigress1 2 ปีที่แล้ว

      @@comp3interactive Definitely not trying to speak badly of Brackeys, I owe most of my knowledge to him :D
      I finally got the code working I'm happy to say, i missed the last part where you added in the new directory if there wasnt one. Now its just figuring out how to get the values in my game to save to this script :P

  • @donjohnson4347
    @donjohnson4347 3 ปีที่แล้ว

    What if you private your variable how would you save it if it's multiple data, even arrays

  • @manacorda
    @manacorda 2 ปีที่แล้ว

    😀 !! You have a Brilhant brain !!!

  • @ThatOneRobloxDev
    @ThatOneRobloxDev 11 หลายเดือนก่อน

    Binary Formatter got tagged as unsecure, unsafe and untrusted by Microsoft. You should learn XOR encryption or Binary Writer class instead.

    • @comp3interactive
      @comp3interactive  11 หลายเดือนก่อน +2

      It's unsecure for data transfer and shouldn't be used for networking paxkages, using it locally for a game's save file is perfectly fine

  • @iunholy
    @iunholy 3 ปีที่แล้ว

    Hey I struggle with: if there is no save data to load, instead of return null, how to create a new file?
    Thank you in advance :)

    • @flaviokonti5522
      @flaviokonti5522 2 ปีที่แล้ว

      If theres no save data to load you just inform user theres no load data and return, why would you want to create save file on Load, makes no sense

    • @TheNbc27
      @TheNbc27 2 ปีที่แล้ว

      @@flaviokonti5522 It does make a lot of sense though, with the current script. If I use it the way it is. My game would be broken. When you're setting items in a scene based off of this save data. If you return it null you of course get a null reference exception.
      Ex. My game starts up for the first time and attempts to load, file exist returns false and sets my saveobject to null. Which in turn now breaks every single thing that is set of off this data.

  • @darytuto
    @darytuto 3 ปีที่แล้ว

    Good tutorial. But load does not work. How To solve it

    • @comp3interactive
      @comp3interactive  3 ปีที่แล้ว

      Follow along with the tutorial again. The loading works the way I describe it

  • @sandeeproy3126
    @sandeeproy3126 2 ปีที่แล้ว

    I want to use this system to store the data on the amazon s3 bucket , for all my players game state , but the really problem that is bothering me , what if I want to add new features to my game , how shall the file schema change can be implemented upon the existing binary files , plz someone reply

    • @flaviokonti5522
      @flaviokonti5522 2 ปีที่แล้ว

      Dont use files for this, save stats in database

    • @sandeeproy3126
      @sandeeproy3126 2 ปีที่แล้ว

      @@flaviokonti5522 I am using database for stats , but its more kind game , there are going to be lot of data related to grid map ,positioning , buidling levels , troop etc , so i am thinking about saving all this state info in files , am I wrong ?

    • @flaviokonti5522
      @flaviokonti5522 2 ปีที่แล้ว

      @@sandeeproy3126 I would avoid using files for anything except basic savedata or scriptable objects and only localy on device, but thats me personally! Try and see how it works, maybe it works great then comeback here and let us know.

    • @sandeeproy3126
      @sandeeproy3126 2 ปีที่แล้ว

      @@flaviokonti5522 ok i will test it than , i am also lookin mongodb as a alternative

  • @dannys.3752
    @dannys.3752 4 ปีที่แล้ว

    I got this strange Error message :
    ArgumentNullException: Object Graph cannot be null.
    Parameter name: graph

    • @comp3interactive
      @comp3interactive  4 ปีที่แล้ว

      Do you have a variable named Graph in your script?

    • @dannys.3752
      @dannys.3752 4 ปีที่แล้ว

      @@comp3interactive Nope

    • @dannys.3752
      @dannys.3752 4 ปีที่แล้ว

      @@comp3interactive I tried to save via Button
      public void LoadGame()
      {
      Debug.Log("Load Game");
      Folder = SaveController.LoadGame();
      }

    • @comp3interactive
      @comp3interactive  4 ปีที่แล้ว

      Hmm I'm not sure then man. If you remove this script then does it work again? Because this doesn't use anything called Graph so I can only assume it's an error with a package you may have in the project?

    • @dannys.3752
      @dannys.3752 4 ปีที่แล้ว +2

      @@comp3interactive Found it ! SaveObject was still a MonoBehaviour i didnt chage that. Thx for Help and Best Tutorial on Earth !

  • @rowel9785
    @rowel9785 3 ปีที่แล้ว

    Do I inherit from the save object class to put add other variables i want from another object?

    • @comp3interactive
      @comp3interactive  3 ปีที่แล้ว +1

      You can tweak it to use inheritance 100%. That's the way I often use it myself, this way was a slightly simpler way as an intro to binary Serialization. In this method I just use SaveObject as the literal object and throw all my savable variables in there though

    • @rowel9785
      @rowel9785 3 ปีที่แล้ว

      @@comp3interactive Thanks for the resposne :) I wonder if formatting works with arrays and lists too? since I plan to save Savable GameObjects in the scene.

    • @comp3interactive
      @comp3interactive  3 ปีที่แล้ว +1

      Good news. Lists and Arrays are serializable! Game Object however, arent. You'll neetocrrate a cusm class that holds position, rotation etc and save thag

    • @rowel9785
      @rowel9785 3 ปีที่แล้ว

      @@comp3interactive Thank you very much! this has been really helpful, I now have a clear idea on what i have to do now. Hats off to you good sir :)

    • @comp3interactive
      @comp3interactive  3 ปีที่แล้ว

      No worries my dude! Good luck with the game

  • @TheCheldthorpe
    @TheCheldthorpe 4 ปีที่แล้ว +1

    Some great content on your channel but would have to disagree about Binary format.
    For one you can not serialize monobehaviours with out creating an extension method or arrays of floats ect.
    Also binary is no safer than xml or json as long as you know your lives/health/score values these can be simply found in a hex editor with a simple decimal search.

    • @comp3interactive
      @comp3interactive  4 ปีที่แล้ว +3

      Thanks for your comment. When it comes to serializing MonoBehaviour scripts I wouldn't see a benefit of doing that anyway? A MonoBehaviour relies on being in the game scene to be really viable, if its transform data you're wanting to save then this is where ScriptableObjects come in handy.
      I'd still argue that binary is more secure than XML as its not in a plain-English format, you can definitely edit it with a hex editor (as I do mention in the video) but that requires knowledge about that which, if we're being honest, not many casual gamers do

    • @TheCheldthorpe
      @TheCheldthorpe 4 ปีที่แล้ว

      This is fine if you work in 2d but if you want to track/respawn or mange anything to do with positions in a 3d world having a float array with 7 options for a quaternion does not seem practical when you can use json/xml with vector2/3/quaternion ect.. then a simple pass with Aes or any encryption will stop anyone from from reading your data.
      As for scriptable objects if done well your data manger is effectively a scriptable object anyway everything can talk to the data manger and be decoupled from each other.
      I am not out to cause an argument as i said i like your content i just disagree with bin format.
      Don't underestimate the youth of today when it comes to cracking stuff either they are clever little sods.

    • @comp3interactive
      @comp3interactive  4 ปีที่แล้ว +2

      Yeah I know man. No arguments here, everyone has their preferential way of doing things. Not everything will work for every situation in ever case

  • @GymCritical
    @GymCritical 3 ปีที่แล้ว +1

    While this tutorial is among the best I’ve seen, binary serialization is NOT safe for use. Use an alternative like JSON if possible!