 Hello guys, it's Crypto Grounds here. Welcome back to another idle game tutorial video. This is gonna be a very You guys just copy and paste kind of a thing because What we're doing today is like an advanced save an export system or an em in it that and import system and It's gonna be a lot of work. So So just be aware this is gonna be a boatload of stuff and you're probably gonna get some air so Pay close attention to what I do So first off we need to create a new so I'm just gonna jump right off the bat We need to create another class and it can create it in another script or the same script But I'm just gonna stick with the same one just because it's easy, but I'm gonna call it player data You don't need a mono behavior for this Basically what we're doing here is instead of doing player preps We're gonna save everything into a JSON. If you don't know what JSON is it looks like this. It's like Key it's a key or a name Key and then it has a value right here a number string Bull anything like that and then it's just a list of this stuff Looks like that But ours will be low-clustered. It'll look like this I'll probably look something like this Something like this because of how our big double it saves us two independent variables because it's because of If you don't remember from our previous video from here, we have variable one variable two, but It's not really relevant. If you don't if you don't want to understand it Okay, so let's just move start moving everything here We can keep our text where they were just need to get all of our costs Okay, here we go So we're gonna get a bunch of red now. So up top we are going to do we're gonna call this class called public player data At the big get this is gonna get a lot of work. So just a FYI, but we can get rid of this load thing now the save and load What's this right here? Oh, we forgot one. Okay We can get rid of the save and load method at this point. We really don't need it, right? Nope, we don't need it So at this point all your data if you if you if you've already published your game or something like that And you change it your your data is just gonna get screwed over no minute I mean if you're really wanting to like have a method that automatically moves this to this and Then delete it at this. That's just yeah, I Rather just sacrifice all the data. That's what happened to my crypto clickers. I just I just ditched it I just got everyone to start over. It wasn't big of a deal Okay, so now at the beginning of every single one of these we're gonna put data dot Because we're accessing the variable inside the the player data class So I'm gonna do this real quick Okay, so here we're gonna get rid of this all this stuff here for the full reset Just because we're gonna add it to our player data class. So I'm forgetting a few things We're good to go. So here We are going to make construct their method which basically it assigns The point of this is on when it's called when this class is initiated right here All of these variables is So this is initiated every time this class is initiated, which is when the game runs, of course All these variables need to be set to something like you can't just make if you set it to two. Yeah, but that Really, it's different than making a constructor and Constructor you could set it with whatever you want because if you set like this to four and they oh I want to set this to five the next time I run it. It's not that change unless you have this This public Public player data, so there's no void in this too. It's just a public player data and We are going to grab all these variables right here. Oh actually We're not gonna do it in here. We're gonna make another method called void free full reset So this is our full or full reset right here now We're gonna paste them in here Set all of our default variables to what they were so now the thing is I don't remember why I said them originally so I'm just kind of have to guess. I'm guessing that's a one zero zero Zero I can copy and paste this zero zero zero one zero And then we call this in our player data or player data constructor and If you go all the way back down to this full reset we call it down here. That's because we can't one in our Unity We won't have any access to the variables in here. We don't have any access Now I don't know why you need hasn't I Like came up with a method to do this But my best guess is because there's no motive behavior and we can't have this because it kind of screws up with our encryption So here we're gonna call this I Think it's serializable. Yep. So that means we can take all this data into a bunch of ones and zeros All right, sorry about that. I had to do something. Where was I? Um, I think I was at where we take all this data to bunch of zeros and ones and we are able to save that So I think we're done here. Oh, yeah, so we're done with this script for now Or not completely done, but we're almost done So here's the copy and paste B. Yeah, so we have to do we're gonna make we're gonna make two different scripts Actually we only need one okay, I forgot I merged two scripts into one Call this save system So this is gonna be like you're gonna look at this and you're gonna get really lost like trust me I don't understand what a huge majority of it means because a lot of it is related to Encryption like double-air encryption. So I'm gonna copy and paste it. So just be aware Okay, my bad. All right, I want you guys to copy and paste this code All right, yeah, this is gonna be a build load. Okay, just be aware All right. So here you go. I'll kind of scroll through it. Okay So you guys can pause whenever you should get it a few things we need to fix This is for my crypto clicker script. So you can change that to player data, so it's not red You're rid of that red And so this right here a theory of controller. This is going to be your idle tutorial game your main scripts, basically Oh, yeah, we can delete this too. We don't need this knowledge just for me What else is red? Offline progress check Okay, so this is offline progress which I've done in another video I can honestly do that in this episode since we're doing a different save system, but It's honestly kind of the same Okay, so basically what this whole script does is that it takes all of your Variables here all your data it Converts it to JSON which and then it's converted to string and then that's saved into a text file Oh, yeah, no, so it's converted to JSON and then it's encrypted and encrypted again And then and that is saved to a text document It's saved to two text documents in fact One of them is this main one right here and then there's a backup one this this one Happens every five saves just in case there's something wrong with that one save that could have corrupted and I've actually without this backup I've had a lot of issues with corruption and this backup has saved me Save players every single time. I haven't gotten a single complaint about corruption and their data since dawn of time of this Creation right here Another thing I want to keep you aware is that When you delete your app or whenever whenever something bleeds your game this data will disappear It's not a cloud save that I don't really know how to do cloud save. I don't want to get the cloud save just because You can simply just copy and paste this What with the export you can copy and paste it and save it into a note a note file The problem is that The string is gonna be very huge. It's gonna be with my game. It's at least 25,000 characters With this game will probably be around maybe a few thousand just because of probably maybe like a thousand Just because of how little variables are anyway, it's just so here You need to create a 16 digit or a 16 character along string between with Lowercase letters actually I don't think that matters But I would use numbers and letters that don't share it with your community year So they're gonna be able to debug your your save and cheat Same thing here, this is a 24 string 24 character string I don't think it really matters how long it is But I would just do 24 just to be safe case it screws up and don't use any like dashes or anything This is numbers and letters only that will mess everything up. So numbers and letters only You could change you could choose whatever kind of path you want. I'm gonna do Tut save I'm gonna do Save dot Tut Make sure it's not like a like a dot exe or else. That's not me. You know, it's not gonna work Idle tut save Or dot I'm gonna do idle tut save and this one will be idle tut backup dots save So it can read and write to these So at first whenever you run it, you're gonna get you might get an error saying that you don't have like the rights to Edit or make changes to this location. I ignore that. That's just something that I can't figure out with the This thing right here, which I've been trying or me and my helpers I've been trying our hardest to figure that out and I we're doing good so far. We'll see about that So, yeah, I think that's done. This is all the encryption bullshit right here Yeah, it's called a yes if you want to do some research on that so basically it it It converts from AES to Base 64 so it makes it more readable or not really readable, but it doesn't look like a bunch of gibberish If you've ever played anti-matter dimensions, that's basically what it is That's what your save looks like and if you've played my game before that's that's also what it is, too Yeah, it's kind of easy to implement want you Yeah, you want to understand it so back to the not the script back to your tutorial script or your main one On start I want you to Do We need to call oh wait We need to do safe system dot load player And in here we need to do Data we should put data in the method. I think we need it. Yep We need to do ref the reason why we're doing refs because we need to directly change These variables Because by default they're gonna be zero every time we load me zero or one or whatever we set them here We need to change them. So that's what this load player will do They'll load the saved data that I've been them whatever changes we've made And we'll replace it. So we got the load and for the save It's save system dot Save player It's things just data, right? Is that it? Yeah That's it. Okay, so At this point, it's just it's just a bunch of UI stuff that we need to do and Crossing our fingers that'll actually work This is never used You This would happen. I think well the reason why is it's not it's never used is because We never actually use the variable itself. It's just that whenever we get an error It's just gonna debug this it's just gonna print out of that, but that hasn't happened yet And usually when that happens I get another error so When it when it comes to decryption Another thing is that if you copy my save from this games import system It's this is not gonna work because we're gonna have two different keys And that's why I kind of made this right here. This is not my key So I use a different key. So make sure you change them So now that so that everyone who's making this video aren't using the same key because I'll be kind of I'll be kind of not good So we're gonna make a Up a settings button. I'm just gonna use this right here. What is wrong with you? There we go Don't know why are you are you I looks like crap? Oh, it's because it's a bun. That's why That's why it was stretched You know these dumb errors I'm just gonna put this in the corner right like so and That can be our settings button and now we're gonna have a setting screen So this is gonna be a little different. This is gonna be like a whole new game object Yeah, so Hmm, this is the button. Oops We're just gonna get rid of all this settings screen I'm gonna put my background back in here. Oh Here it is Okay, I'm gonna replace this with a new background here So it's on top of everything because I really don't want to mess with canvas groups for this I don't do that with any of my settings. Ah shit Make sure it's stretched out and change the anchor so it stretches Now we can add an image. Uh, I I guess that works. We can just add an image to the game object that works, too There you go. So this would bear a setting screen settings We also need a back So I'm gonna take the setting button again White Okay, now with the actual settings. So there's gonna be quite a bit we have to do here. Okay We're gonna need a few buttons. We're gonna need a manual save Because people like to do that We need an X in and out import and export so import Export And we're gonna need a text mesh pro input field We're gonna import these again. I swear. I have to do this every time I launch unity. I don't know why Brecks I'm done with this project. So we're gonna need two of these and The reason why we need text mesh pros because the regular unity input fields limit the characters to like 6,000 I think so these will make it unlimited or actually this might be up to like 32,000 I'm not really sure but I know that is that they can store really large Chunks of text So we got import Export I could have honestly just copy and pasted these buttons here. So these are ugly one two three Play some however you want. I really don't care So this is gonna be our save. We're also gonna have a Another button. This is gonna be a clear fields because it's kind of easier to just make sure you have an empty Okay, it's gonna be kind of messy I'm really bad. I'm making looking Making good-looking settings, but I'm just kind of not really trying at this point But the the looks of this setting page manual save or this will be save import export Clear fields Okay Okay, now back to our input fields. You can do whatever you want with these. This is gonna be my import This is gonna be my Export and don't know why this doesn't say insert text kind of weird You see that doesn't doesn't show Gotta make sure this is Shucked down to its size Yeah, don't know that's a little weird. Whatever Source inch Okay Let's just customize this I'm gonna make this bold. Yeah, that looks fine to me You can make it run on as long as possible Let's make this text multi-line line limit zero There you go. Holds on the limit to an amount You can do the same thing here. Okay So now we have to access all this stuff So we need to have our safe system script Save system get rid of this That's safe system. Okay, so we have our import input field and our export Encrypt decrypt value, what are these? Oh That's just that's for me only here. I forgot to get rid of two things Where's my script? Where'd it go? Okay? So I made you you can decrypt your and change your stuff by Debug logging it you can really just I'm gonna keep this for you. Actually, I think you need this. Do you? Doesn't look like you need it Okay, so here you can test the encrypt encrypt Yeah We can get rid of these Okay, so it kind of screws up here Decrypt value text So here you can see What like what things actually look like if you wanted to it's because this this basically decrypt your save So, I mean if you really wanted to you could do debug log Just print that Same thing here But I'd wreck yeah, you can keep this if you want to I Don't remember if we needed all this or not. Oh I'm gonna just cancel this. I don't I really don't know what I don't remember. I don't remember using this at all I'm just gonna delete it See I make sure you delete the encrypt. I'm gonna I'll show the code at the end Yeah, I'm telling you this whole safe thing. Just fucking shitload of stuff to do Okay, so now instead of game manager, we need to drag our save system. I think that's it This is it. Yeah. Okay. So we have our import May she in the import may she drag your game manager into here Since that's your script that you're using drag save manager to your export and Click export player to that. This is just the method name You can change it to export player if you want to but I just forgot to mention that Okay, so save your game this might not work. We will see though. Oh, I know it doesn't work Yeah, so here's the sharing violation my god Export Okay, this doesn't I think this is it it didn't look like it So, okay There's one way to test it which is to actually like make our buttons do something first public game object settings Oh my void go to settings Settings that game object that's set active true And I'm gonna make another one call to go back from settings Go back from settings Of course, you could use Canvas group change if you wanted to if you added a canvas canvas group to it. Okay, so save Back when we got back button do something Drag the game manager go to idle tutorial game and go back from settings Where is it? Where is it? Where is it? There it is? And then we're gonna do the same thing the settings and go to settings save it again So let's let's give us a shot Okay, clear fields is not in the setting screen like it should be All right, so we're gonna have $28. We're gonna quit out of it Cross our fingers. Oh So go we got our save now. Let's try exporting it. So we're gonna copy this Click some money Save it one more time. We should have $42 Okay, now we're gonna import so this should be $28 import boom We got it So we can play around with this a little more to So let's track this where it should be Okay, so this setting screen should be disabled Save So let's have a little fun with this. Let's buy some upgrades That's right. Let's click So we need to test all the save things here okay, so Here comes our production Our production upgrade twos upgrade is not working. I'm aware of that. I think I forgot to finish something with it. I Think I've said that in another video Okay So we're just gonna let this run So while this is running, I'm gonna show you where the file is actually saved. So you're gonna this PC Yeah, I know I'm not a slurrage users Your your username app data local low So this should this is gonna be called default company until you give it a name You'll find all your games here and ours is idle game tutorial series Unity shoot wrong folder wrong folder. It's actually it's local. I think No, is it running? Shoot, where is it? Okay, so this cryptograms Okay, so it should be default company. Oh Here it is. I'm very blind. Yeah, here's your safe files. So now you got to open with This is I don't know how to find it on like a mobile device, but I sure know how to find it here So, yeah, here's our safe file right here Good view. Yeah Yeah, that's what it looks like now, I'm not sure why it's doing a bunch of new lines, I think that I don't that's just formatting Yeah, here we go. Here's our safe Let's see, you know That looks better. Okay. Yeah, that's that's where your save goes Okay, now we're gonna save this one more time make sure everything here is saved beautiful awesome, so Yeah, that's basically the save system With the export and import now, this is something you probably don't won't ever see on YouTube till today Anyways, I hope you guys enjoyed this video. I hope it wasn't too confusing While I'm talking I'll scroll through my script one more time Yeah, sorry, it's a really long time since I've uploaded on this series I've been really busy and I wanted to do the clicker heroes Series because why not and I thought it would be fun one and I can also Remove some episodes. I was gonna do here and I put it in there like animations and stuff. I however here I still need to do offline production because of this new save system and You should be able to implement this with the clicker heroes to game to Yeah, this is really good to use ditch player press as soon as possible It's shit. You cannot export and import easily without having to get deep into your device And it's just a mess not worth it. You should do this instead. It's a little complicated But you don't need to understand it to get it to work. That's just a good thing So anyways, I hope you guys enjoyed this video if you guys haven't yet I should check out my kofi account. I have gotten my first donation Oh shoot, I need a login. I was gonna give someone shout out Not no received given So, yeah, someone named final cloud has given me first donation. Thank you very much. I've been helping him a lot On a reddit so yeah shout out to this guy. He's amazing Oh yeah, I Really appreciate it and it means a lot and you guys want to tip in to go ahead and just three dollars is would make me happy and Yeah, make sure you check that out if you're interested and also check out my Pinterest as well I know not many youtubers use Pinterest, but I'm kind of just trying to grow my awareness on My idol games on Pinterest. This is not made too much idle games on here. So I'm trying to like increase it Get as many outside of the idle game universe into this You know kind of tutorials because I feel like it's good for people to learn and stuff like that So I post like my game screenshots. I post like like three pub a lot of things Tutorial series. So yeah, I did that kind of stuff. Anyways, don't forget to hit that like subscribe and turn on notifications Hope you guys enjoyed this video. Have a great day He's trying to take away my cell phone like coming party. I've been trying to take you off my mind But just can't get you off me keep it moving. They ain't worth it. Yeah, that's what my father taught me But for now I'm going through the motions of letting go My heart really don't know your heart when I got to know it yet I still see a glow so we had the hottest love. Why'd you leave me in the cold?