 Hello guys, Crypto Grounds here. Welcome back to another Unity C Sharp Antimatter Dimension video. This episode is 7 and today will be a short one. Today we're going to be doing the save system. And I'm going to be using the save system based on our recent save system video on the idle game tutorial video and our tutorial series. So we're going to be using that one. And I will provide the scripts below. Okay. So yeah, make sure if you enjoyed this video, make sure you smash the like button, subscribe to my channel if you're new, turn on some notifications for future videos and live streams. And let's get on with it. I'm sorry that I've been really inactive lately. I mean, it's been the release has been crazy. I've had crazy amounts of stuff to do the week in my personal life has also been kind of crazy. So I was going to make a video last night, but I just got busy. I just got busy with other things. So I'm really sorry that I haven't been uploading in such a long time or not as much as I used to. I promise I'll try to get back from that schedule. Once the once the Crypto Glicker starts to calm down a bit, calm down as in my list of to do starts to reduce. But yeah, anyways, if you haven't installed it, make sure you go check that out. It's on steam. Oh, you can check out my website is CryptoGroundGames.com and you'll find all the download download links there. Okay, so let's see. I'm looking I'm currently looking for my save system, but I'm having I'm having issues focusing right now. Okay assets. So again, you just got to go to the description or the comments where I've already decided to put it and download it right there. I'll make sure there have been links. Okay, shoot, where is it? Okay, save system. I think that's it, right? Yeah. Okay, so I'm going to copy this into our scripts folder. Make sure you call it save system.cs. Okay, so you for you, you just create a new script called save system. Okay, so now we have that. We will have to start moving all of our data and everything into there. We should get some errors. Yeah, okay. So we're going to delete some things because we don't have offline progress in here yet. I don't know when I'll actually do that. But we'll see about that. Okay, so we are in our save system script right here. And here we have our simple AES class and our save system class. Okay, so there's nothing we need to do in here really. I mean, yeah, I don't want to do that. So for this for the init vector, make sure you change this to a different string and make sure it's all lowercase and it can have numbers in it and it must be 16 characters. So if we count this out should be 16. And it is, so make sure you change that up because if everyone had the same init vector, then everyone can just cheat their saves. And that would be kind of an issue. So we're going to get rid of some other offline stuff that we don't need. This encrypt key as well can also does also needs to change. I think this is 24 characters, I may be wrong. But just make sure it's the same length as this one. It's all lowercase and numbers two. This await get UTC time can go. And again, I'll do this all for you. I'll just delete all the stuff that we don't need. Delete offline. We just need to get the load player and all that working. I think we're set. Yeah, so we don't need to change any like the data stuff because we use the generic type here. So it's already predefined based on what we're doing here. Okay. Okay, so let's head to our main game controller. This is we're going to be saving our stuff and loading. So let's start with saving here. Let's also add a public float save time. Okay, and we're just going to set we're just going to have an auto save for for 10 seconds. Okay, make sure you have some kind of decent interval, like 15 seconds or above, because if it happens super often, then it can cause issues. Why is this time dot delta time? Okay. And basically, if we're going to put this at the very bottom, below everything, right? So basically, if save time is not greater than or you can literally just say, if save time is less than 15, then we're just going to return it. So basically, if it's less than 15 seconds, then we're just going to keep returning it. Otherwise, if it is, we're going to set it to zero and start saving. Okay, so what we call here is our save system dot save, save player. Okay, we also give it a type. Let's see what's our data, it's just data, right? So we give it a type data. This is optional for this, you'll see why. And in here, it says, so we have our data right here, our object type, you need to put in the type in here, our data and a string for it, which is where our file is going to be called. So in here, we just put data, and then I can just called main data or something like that, or just data, that's fine. Okay, so now you'll see that this is redundant. So we can just get rid of this because we already predefined our type right here. Okay, so we can just get rid of that. So we have saved our player. Now we need to load our stuff. And we're going to do that the very beginning. So we don't need to load this every time. So what we can do here is get rid of this, actually, we can just set data equal to save system dot save or sorry, load player. And now for here, we have to specify the type for this. Okay. And then here, we since we don't have an argument for what our object is in here, we just only have a string arguments. Okay. And here we put in data, because that is the file that we're loading. And there we go. So there are some safety precautions we want to do. We want to check to see if the safe system file even exists. Okay, so what we can do is save exists. And it asks us for our key. So we just do data. So if this data file already exists, then we're just going to load in this right here. If it doesn't, then we're going to do save system dot, I think. No, we just do new data, right? So we have this originally where we created a new data object on start, right? But now we only need to do this if this data file doesn't exist. Okay, so we set data equal to save system, save system dot save exists, and the keys data. So if it exists, then we're going to load this player right here. If not, then we're going to create a new player with the specified defaults that we have in our constructor. Perfect. So that is a very easy saving and loading system. And it should work perfectly. So let's give it a try. Also, I do have import and export player, but I don't use them. Well, I'm not going to use them. So we might see some errors. Let's see, let's give it a shot though. I don't believe we need to create an object for it. Nope, we don't. Okay, cool. So now let's let the gameplay auto save. So let's find our directory. Okay, so if you've watched that video in the past, I explained where everything is saved. I'm going to show you again. But let's see where is my path right here. So application dot persistent data path is a certain path that is hard, like hard locked for every single device, right? So for windows, for example, ours is located in, excuse me. I have it right here somewhere. I'm just blind right here. So it's located in app data, your username app data. Look below, well, crypto grounds, and then your game name right here. So remember, so our project name is called anti matter dimension series. So if you go to player settings, that's this right here, the product name, and your company name. So basically, it's located in your company name folder. So crypto grounds, for me, anti matter dimension series, which is the product name. And we also have our saves and our backups folder. So see, we have a backup save right here too. And we have our actual save or data right here. So yeah, this code is pretty lengthy. But yeah, we have it right here. Cool. So now if we quit, it should save and load. So we know the saves works, but does the load work? Yes, it does. Perfect. So now I'll make the future videos a lot easier. And I can actually start playing this on my own if I wanted to. Obviously, there's not enough content. And I'm not sure what to do next. I think I should jump to achievements because that will help me a bit. So I'll probably start some achievements next video. Anyways, I said that this will be a very quick one. So I hope you guys are happy with that. Anyways, if you enjoyed this video and learned something new, make sure you smash a like button, subscribe to my channel for new and Toronto's notifications for live streams and videos, comment all your feedback, questions, compliments, all that good stuff below. Anyways, thank you guys for watching and I'll see you in the next one. Peace.