How To Save And Load Your Game Data With Scriptable Objects - Unity

Поділитися
Вставка
  • Опубліковано 30 сер 2018
  • Help to support the channel if you are feeling super kind: / dapperdino
    Join our Discord: / discord
    • Unite Austin 2017 - Ga...
    • Unite 2016 - Overthrow...
    In this video I show you how to save and load your game data in Unity with scriptable objects.
    -----------------------------------------------------------------------------------------------------------
    If you liked the video then please respond with a like and a subscribe to show your support for the channel and I'll repay you by creating more tutorials to teach you the wonder that is Unity :D
  • Ігри

КОМЕНТАРІ • 58

  • @bleblekime1815
    @bleblekime1815 4 роки тому +10

    I've just realized something interesting: if you save this as a txt and try to open it in Sublime Text, it will show up hexadecimal code. However, if you use notepad, you will be actually able to see values and edit them.
    EDIT: Turns out you actually cant serialize scriptable objects. Even if you are will open sublime text or vs and see hexadecimal code, by opening you save the file by notepad you will be able to see and edit values. What you have to do is to create another object that is a pure c# class and load your scriptable object data to it. After that, you can serialize it and it should work properly.

  • @sherlyhudson2198
    @sherlyhudson2198 5 років тому +20

    Can you do a tutorial on inventory system that you can save and load?
    Saving string, int and float seem simple enough, but when it comes to inventory I have no idea how to implement it because there are images and slots etc.

    • @sus7820
      @sus7820 3 роки тому

      Hey you still alive??

  • @kapkoder4009
    @kapkoder4009 3 роки тому +3

    THANK YOU SOOO MUCH!!!! IVE BEEN LOOKING EVERWHERE FOR THIS!

    • @kapkoder4009
      @kapkoder4009 3 роки тому +2

      @Skippy_xD don't tell anyone I watch tutorials

  • @dlxinteractive
    @dlxinteractive 5 років тому +5

    17:49 how come when i saved my script to PlayerPrefs and open up the text file that stores my script it displays it in JSON but not in hexadecimal? it displays this: ÿÿÿÿ |{"startingHealth":20.0,"health":20.0,"moveSpeed":9.0,"crosshairs":{"instanceID":1009186},"deathEffect":{"instanceID":27244}} (yes this is the player script).

  • @CDJaramillo92
    @CDJaramillo92 5 років тому

    I'm trying to save the game and if the game is open again has a button to load a scene but with the current progress. what would I do?

  • @brendaschmidt3028
    @brendaschmidt3028 4 роки тому +2

    My big question was if it would save a private field if it had the [SerializeField] notation. Just for others who might be wondering - it does. So you don't have to have your fields set as public. You can have serialized private fields.

  • @duskjk1258
    @duskjk1258 2 роки тому

    You are amazing. I have been looking for a method like this in which c# that how can I save whole class object data in a file. This json code is perfect. Thank you!

  • @RonBonomo
    @RonBonomo 5 років тому

    I tried this, but it doesn't work if i try to save a list. It wont reload the list. When I am saving I use List items, i will put items int the bracket (json, items). But this doesn't seem to be saving or loading the info in the list. Could you tell me what I am doing wrong, if I am missing a function or something for saving a list that changes as game play goes on

  • @DustVoltrage
    @DustVoltrage 4 роки тому +3

    Even if's a really good one, I have to say there are millions of these tutorial out there.
    What the community would really need is the more complexe situations : saving derived class from scriptable objects, non serializable stuff such as sprites and so on !
    Please Dino

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  4 роки тому +4

      I'll do a more in-depth example next week that is more practical for bigger games :)

    • @DustVoltrage
      @DustVoltrage 4 роки тому

      @@DapperDinoCodingTutorials awesome news !! 🙏

    • @ozeistudio6916
      @ozeistudio6916 4 роки тому +1

      @@DapperDinoCodingTutorials am at 3jin but is this working with mobile ?

    • @oGSS52o
      @oGSS52o 4 роки тому +1

      @@DapperDinoCodingTutorials Still planned ?

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  4 роки тому +1

      I really need to make a public schedule so people can see what I'm planning with upcoming videos :p I will be doing a video today and tomorrow for Unity ML agents since they just came out of preview a week ago then I can do a video on more complex saving next week.

  • @jamiebates5522
    @jamiebates5522 6 років тому +4

    RIP Bob, overwritten by Bill in his prime :P I guess if you wanted the filename to be a bit more mysterious than 'slot1.save', you could create some kind of hash using the filename and then use the hash as a filename instead. Very informatative, thanks for the video!

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  6 років тому +1

      Yep, it's really up to you for deciding how secure you need or want it to be. I'm glad you liked the video :D

  • @charlenejoyconcha3502
    @charlenejoyconcha3502 3 роки тому +1

    can i save a data without replacing the old data? Can i CRUD this scriptable obj?

  • @michaeldiaz4285
    @michaeldiaz4285 2 роки тому

    this tutorial was lit and str8 up to the point

  • @dan-mechanics2014
    @dan-mechanics2014 4 роки тому

    This is really awsome

  • @ImmortalityYT
    @ImmortalityYT 5 років тому +4

    Thanks by far the best tutorial I've seen on the topic! This is a dumb question but is character a class?

  • @kazimashiatsumaira1684
    @kazimashiatsumaira1684 Рік тому

    Will this work after we give build, play game, quit application and then reopen application?

  • @theRealDonaldTrump666
    @theRealDonaldTrump666 5 років тому +1

    thats auto save fast. no more waiting 30 - 50 seconds to save because i have 50 values that need to be individually sent through the pipeline. a few times in the past i wasnt sure if unity crashed or if it was doing it. i couldnt click on anything

  • @dannykessel6634
    @dannykessel6634 5 років тому +2

    It worked when I was still building (and testing it) in Unity. But after the Build, the safe doesn't work anymore. What could this possibly be?

    • @judgegroovyman
      @judgegroovyman 3 роки тому

      I know it’s been a long time but as I understand it scriptable objects can’t be written to in a build. Has anyone found out otherwise?

  • @nemogames5354
    @nemogames5354 4 роки тому +1

    I used this method and now im getting a lot of Type mismatch

  • @lonemastery
    @lonemastery Рік тому

    is it better if you use playerprefs?

  • @user-kp4by9cg2e
    @user-kp4by9cg2e 2 роки тому

    Thank you, solve my problem!!

  • @apurvasurve3294
    @apurvasurve3294 5 років тому +1

    @DapperDino what is application in application.persistentdatapath where did you create that folder

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  5 років тому

      I didn't create it, it's done automatically by unity because different operating systems use different file path structures. It essentially does the hard work for you when it comes to choosing where to put save data on a users device :)

    • @apurvasurve3294
      @apurvasurve3294 5 років тому +1

      @@DapperDinoCodingTutorials when i add it in my code no option for application comes in suggestions, also it does not turn green

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  5 років тому +1

      @@apurvasurve3294 It's part of the UnityEngine namespace so it should appear: docs.unity3d.com/ScriptReference/Application-persistentDataPath.html

  • @Luluskuy
    @Luluskuy Рік тому

    Hi!
    Do this work on android? Is the path directory same?

  • @iamgingerbread6558
    @iamgingerbread6558 10 місяців тому

    Very Big Wow super Helpful you.Thanks !! xd

  • @angelaaliangan2918
    @angelaaliangan2918 5 років тому +1

    lol public Character is not showing dude . my script got an error

    • @VoltFall
      @VoltFall 3 роки тому

      same any solutio- wait oh you have to watch his previous video to see the character

  • @alinazari2046
    @alinazari2046 4 роки тому

    Holy Ricksus , i just saved a ScriptableObject with huge data and reloaded it on Android O_o

  • @Zenkoreal
    @Zenkoreal 6 років тому +1

    Can you make a video how to make team bot for discord???
    So you can !team create
    And invite other people (max30)? I actually need it for my discord , but there arent any tutorial

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  6 років тому

      All you would need is a list of members and to add the person to the list when they use the command. As we are currently building our branding and website/server with the channel we will be creating and selling specific, fully functional bots on our website, such as a scrim bots and so on due to the fact that we currently have no form of income and it costs us to do all of this.

    • @Zenkoreal
      @Zenkoreal 6 років тому

      Dapper Dino - Coding Tutorials ok but i know nothing in coding so im trying to look for someone can made it or a tutorial

    • @DapperDinoCodingTutorials
      @DapperDinoCodingTutorials  6 років тому +1

      As I said, as one of the only possible ways for income we are creating and selling specific bots, either that or you start learning some basic coding because we don't just give out code for people to copy. We are here to teach :p

    • @Zenkoreal
      @Zenkoreal 6 років тому

      Oh ok , thanks

    • @Zenkoreal
      @Zenkoreal 6 років тому

      How many for this bot?

  • @bobsjobisfob
    @bobsjobisfob 2 роки тому

    i cant believe this didnt work AND i also had to copy it by hand

  • @charlenejoyconcha3502
    @charlenejoyconcha3502 3 роки тому

    Hello guys can you help me. I have multiple accounts, leaderboards, trophy room and assessment record for my toddler game. but unfortunately i dont know how to do it because im a newbie in unity world. Is there any tutorials step by step or can you guys teach me how to do a CRUD step by step? Hope you guys help me.

  • @arifharsowiyono7242
    @arifharsowiyono7242 5 років тому

    you not explain InputManager Script dude :v

  • @Aldin101
    @Aldin101 Рік тому

    You should uninstall league of legends

  • @realurah
    @realurah Рік тому

    thanks dude