How to use EasySave 2 in Unity (Save System Tutorial #1)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome from the unity 5 tutorial today and I'm gonna be showing you how to make a save system using the easy save script on the assets star and I'll be showing you how to save and load some simple variables boolean's and things like that and in further episodes I will show you how to go about loan saving your characters position really loading that reloading from a main menu and then re and loading in everything as soon as you seen stats but what I'm gonna do today is I'm going to show you how to easily use the easy save complete serve and Lord asset that's on the asset store the person who developed this plugin is a very helpful and will reply to emails that you might have and will help you pass through it so I thought I'd do a simple thing and go through this the simple setup of creating a basic save system and loading within your game in unity 5 so if you search the unity asset store easy save it will be 32 euros which is about 27 pounds or 35 dollars and if you if you're interested in games development of making games as a even a hobby a business whatever you're looking at its I would recommend doing this and this price is really a drop in the ocean compared to what you get out of it will save you hours and hours and hours of time messing around so what I'll do is I won't go from the basics of it and go into as much detail as I think we need to cover so what I'll do is whenever you gonna make this you want to start a new scene and when you've done that you want to bring in the asset that we're looking for so you want to do that and you want to go to asset stop and you want to go up here to your download manager and then we can search saving at the top and press filter and we will get the easy save and what you want to do is if you haven't already download it and press import and import this package into your new scene now once that's imported you can get rid of the asset stop and there's only one thing in my a project that I've got is I've got the standard assets and I've got the controllers pack which you might want to have an FPS controller to run around I'm just going to get rid of this link because we don't need it for now now in our scene there's nothing going on what won't do is we want to save two scenes out particularly so I'll save this scene now as it's gonna be our level one as an example and what I'll do is I'll serve another scene out save scene as and save as menu I'm gonna have two different so we're gonna have a menu which we can load from and then the level which we can serve and load from depending what we need to do so based on this in our level one and we'll have two buttons in our menu we'll have a button so we'll start with a menu I'll show you basically so what you need to do in your menu to get something working we want to go to game object UI and we want to create a canvas and then it will bring the canvas and the event system what I like to do is create an empty game object so I can put those two things together so I'll put this as menu UI and I will drop these two things in the empty game object and they're just encapsulating this anything now I will click on the canvas then you can press F in your game view and you know it will zoom towards it or we can go to the 2d view and we can see that this is the canvas that we've got for the screen that we couldn't using so whatever we place with the UI if you familiar with the hue is will be straightforward and you could potentially skip this I might put an annotation in the video but if not we can go game object UI and we'll create a button and you'll see that the button there is positioned directly in the center and what you can do is you can leave it there but I'm just gonna put the button at the side here and then what I'm going to do with the button I'll reload rename that button I just click on it twice or renaming at the top here is I'll just call that load BTN I will open up the drop-down and there'll be a text box that we can edit so here and we'll just rename this to load so that's all we've got for now and now menu you can see is if I press play you'll notice that I've got a load button which does nothing because we haven't told to do anything so that's all one I'm good that's nice for the menu for now and we can sell its menu because we can see up here that we're on the menu and we can jump to level one we're at level one now now there's nothing in this scene now there's a few things that were do want to do a similar thing so we'll go UI and canvas then I'll create another game empty game object and call it just save load UI and then I will put the two things that the canvas created together and one object I will go back on the canvas I'll go game object UI and we will create a button then in 2d like we still will click on the canvas we'll have a look where we are you can see that the buttons there down at the bottom it doesn't really matter where we put it we can just stick it in the top corner roughly like that what I'll do is I'll rename this button save BTN o on the drop-down I will rename this button to save also and then what I'll do is I what you will get this button by clicking on it I'm pressing ctrl D and then I will just drag this now and then what we do is we can rename this button to load BTN then we can change the text to load so we don't get confused then what will do for me we'll go off the 2d view and we'll work in our workspace now so what I want to do is I will create go game object 3d object and plane so this is going to be for the floor that we're going to use so for the flower I'm gonna have four different flower pieces so you can easily see where we've moved to based on the save system so what I'll do is I've got a plane there is what I'm going to do is create a material folder and just call it materials and then in that I'm gonna create a new material and hold this red and I will change the color to red duplicate that three more times call this black we can call this blue and then we can call this one yellow for the sake of this and now we're here we've got the plane selected I will just duplicate they blend three more times you can see that we've got duplicates and I will just select them and drag them out into the scene all I need to do is select one plane press V on the keyboard and I will can snap the angles to the corners of the pieces that I want so I can just snap it and now you've got four planes together and the reason I'm doing this is because I'm going to add the colors themselves on the material so I'll change that material is black to a black albedo so I'll drag that on I'll change the blue to whatever blue you might want this is just a visual representation of what we're looking at so you can understand it and we can add red there and we can set yellow to yellow and maybe slightly orangey but it doesn't really matter so now we've got that there we've got four different planes almost now for this I will tidy up by having an empty game object and call this misc for miscellaneous items because we don't really need to worry about it nor do we need to worry about the directional light really we can go into US standard assets go characters first-person controller prefabs and we want to drag a FPS controller in and that's all well and good we've got that in now and we can get rid of the main camera because we don't need it now if I press play you can see that everything's fine there one thing I'll care to mention is if you do put your canvas in your event system inside a SAM to game object make sure position is set to 0 0 0 or these scaling will be slightly out so I can just quickly grab these two objects and just move them up so in our game view we can see it now when I press play and you can see that this save and load buttons that ready for us to do things with and based on our scene view I'll go back into it look at my FPS controller everything's looking good so far what we also want to do is our create an empty game object and I want to have this as an ANA manager object because this is gonna be something I'll set it to 0 0 0 this is gonna be something that we're going to use to explain how it's all going to work I'm just gonna impart in a texture that we're gonna use later on and I'm just going to set this to you sprite and hit apply and I'm just going to set it to 512 I might provide this if people really want it but it's nothing basic it just says saved on it so we'll get straight into it now because we've sort of set everything up and everything that we need to do so far so what we'll do to start off with is we'll create AC sharp script and what I'll do is we'll call this manager script and for the sake of this tutorial we're just going to have this manager script as a pretend way that we're going to control things that we're doing our game and these are the things that we'll want to save and I will go through it as we go through so you know you can open up this in whatever editing program that you've got for coding so what we're gonna do is in this public class for the manager script what we'll do is we'll have a public integer ammo take everything here that's just a pure example and you can do whatever you want but this is to show you how it all works so we've got public ammo public integer magazines and this an example if you're making a first-person shooter game something like that is a pure example we've got ammo magazines both as public integers and then this is an example we've got a public boolean and we can say if we've got a broken arm or something this is just pure as I say we're going to be able to look into saving integers boolean's and saving our players position and then going into doing other things so once we've got our manager script that's all we really need to do and we can just add that to the manager object so you can see we've got no ammo I've gotten our magazines and technically now we've not broken around because we haven't take the box so what we're gonna do now is go create C sharp and we're gonna create the way that we're gonna save the game and I will explain this as we go along so I'll call this simple save and it just telling me to change the line endings but that's fine problems simple save and now we're in our simple save script we're gonna save those things we just created in our manager script so what do we realistically need to do we need to have a way to talk to this script and ask it what this is what we need to save so what we can do is we can add a public game object with two capitals and have this as a just we'll give it a name manager script with a lowercase M and this is going to correspond to the script that we've got then what we'll do is I'm going to write a public void save to brackets then two curly brackets below and we want to make this a public void so then we can use it as our button because we'll do it as a trigger as a salt button event for the button that we're going to use so what we can do is we can write this as if we're going to just declare the script that we're trying to find so we'll say manager script so the name of the actual script and then we're just going to give it a type like or a name that we would as short-handed just like we did up here so we're just going to call this script and then we'll say equal we're going to say equal to the manager script that we created are we referenced up here don't forget component and then two angled brackets and then within the angle brackets we're going to write manager script with a capital and then add two brackets and a semicolon so what we're saying here realistically it was were just saying that the manager script that we're looking for we're going to get the component manager script and then we're going to be able to just save the values that we need so with the easy save system that's been created this documentation online if you need to look into it more deeply let's say but it's very easy and like I said it saves a lot of time because it's all done for you and you start by writing es2 dot save and then we open up the brackets and then we can start by writing like I said that we give this a shorthand a off script and then because we referenced the manager script we can then take any variable or anything we want to save and pass it to this so we can say gamma and then we can put a comma and then in quotes we're gonna write in Amer and then what we're gonna do is we're gonna do a semicolon so what this is pretty much saying is that we're calling the easy save so ES 2.5 and then in brackets script dorama so we're just calling this Emma and then we're saying that we're gonna save it with a file name of ammo and we're gonna say whatever value is inside this integer into that file and similarly with magazines we do ES 2.5 open brackets script don't magazines from we can say coma magazines with a semicolon and that will realistically just save what is ever in our magazines to a file called magazines and yeah again to really bury this home es2 dot save script doll and then we can have broken arm the scripting reference knows what we're looking for working do comma and then we can call this broken Oh add a semicolon we can save that out so that's really nice that's pretty much the base is to saving that script and the values in it and it will create files files so let's put this into practice I will go on to the Save button like I said on here you can see that I've clicked on the Save button in the canvas I'm going to add simple save to it you can see that it's looking for the manager script I'm going to add the manager game object to it then on the on click event in the button I will click the little plus box then what I'm going to do is I'm gonna add itself to the game object that it's looking for so at runtime we are asking what do I want it to do so from the simple saved script we want it to call the function save so it's as simple as that now if you right-click any project and you've employed easy save you can see that you can right click and go to settings and here are a list of settings that you can do you can encrypt your file you can choose where it's going to file there save the file but it's pretty good just set as default you can open up the default save folder and you can see there's nothing there in my cell folder currently because I would not create anything to save so you know it's that any good but if we press play we expect that when we click Save you know you won't actually see anything it's all click Save we click Save did it do anything we can right click on our project go easy save to settings go tools again and we'll can open served folder and it served three different files one for Emma one for broken arm one for magazines some fat in there we've saved three different files with the things in what you're saying well how do we test if that works well we need to create a really simple load scenario so what we can do is we can create another c-sharp file call it simple mode and we'll do is I'll open that up so once we've got simple load up and we will get rid of the stuff inside the class then and then what we'll do is we'll do the same thing that we did before we'll do public game object manager script like we did before save that for now we could do public void load two brackets two curly brackets below then we'll say manager script but we want to make sure that manager script is the capital and then we have script equals manager script with a lowercase don't get component angled brackets you manage your script with a capital two brackets and the semicolon so like we did in the simple save you can see that it's exactly the same reference that were making but we're just making it to this specific to this function so we're not made it for specific to the entire game then we'll do something similar so here we did ES 2.5 and then we specified what we wanted to save here we do script dama equals ES to dot and then we need to angle brackets and we're going to specify what we're doing to load so we want to load the integer and from that is we can operate the brackets and then in corpse we can say what we actually what file we want to load from so want to load ammo so I'll go through it we're saying that from our referenced script were saying we want to give it in here want to push into this file ammo and what do I want to do we want to easy save to load the integer of whatever's inside that ammo the file that we created and similarly with the magazines script dot magazines equals es to then in your angle brackets George for integers because again we're looking for a whole number because we've got so many magazines then in quotes we want magazines spell correctly as you would expect then the only difference is we've got a boolean now that we want to load it so cup script and then we want to save broken amp so we want to fill broken down with something so we said easy easy save to load then in the angle brackets this time just as if we're going to declare a certain variable type old Karla's boolean in brackets in quartz and then Barak and arm as is spelt in the other script so save that that is pretty much the be-all and end-all of that as well so we can go to our load button add simple load to that it's looking for the manager script or the manager game object we update we want an on click event so I'm gonna click the load button I'll do something will click the little plus box will give the reference of itself then we'll be able to access the scripts they're on it will say that for the simple load we want to call the load function so when we do that we expect it to load the things that we've given so as a pure example to this let's say that on the manager you can see there's nothing there currently we can press play we can run around do whatever we need to do this is the game running now so if I unpause this you wouldn't see any you would see they go back to zero if I change any of these values so say now we've picked up to mama over 500 we've got five magazines and we've broken an arm what do we do so from what we did we'll click the Save button it will have overrated all the stuff that was saved originally in those folders and now once I own play you'll see there's nothing there you've got to either say if you go to settings you can go tools open up default said you can see it they're all there and they were updated very recently now if we press play like I said if I go back on to the manager you'll notice there's nothing in there so what we going to do going to expect to press load and we expect from what we'd saved previously we expect it to fill that content in so we'll press load and you can see now it's brought from those files that we just saved we had five hundred and five magazines and a broken home for the instance so we're playing our game and we're doing whatever we're doing we've used up we've used up some bullets with shots and annuals we've got 250 bullets two magazines and now we've used a med medical kit and we want to reset it click Save that's all well and good you can then unplayable and then when you come back to it later there's nothing there load 250 hammer 2 magazines and now the arms not broken anymore so really you just we've just covered a few ways that we can do an extremely simple loading system all we've done is we've got a script which controls how many how much hammer we've got or whatever variables that you want to control though it's a boolean integer whatever values you need then from the save script we've just said were looking for the the actual manager script that we created what saving the es 2.7 script armor and we're giving it an an a name that we want the file to be actually saved out as we're saying we want to save the magazine's very variable into a magazines file and we want to save the broken arm variable into a broken arm then similar with the load we're looking for the manager script again and we're going to pass into that script so we're going to pass into here the easy save is going to load an integer that were looking for which is inside the alma fun we're going to load the integer that is inside the magazines I'm gonna load the boolean which is inside the broken arm folder this is really simple because the same system only needs to be what you specifically need to serve ie specific items whether they've created certain parts of your story been collected certain items and you needed to remember what specific things people actually have and I will be doing a different a more of an extended video to show you how you can possibly go and save your characters position and also save the scene that you're in and be able to load from there so this was just the initial setup and this shows you how you can basically with some simple buttons save and load values that you need in your game extremely easily using easy save so thanks very much for watching and don't forget to Like comment and subscribe Cheers
Info
Channel: SpeedTutor
Views: 57,833
Rating: undefined out of 5
Keywords: speed tutor, speedtutor, easysave tutorial, unity easy save tutorial, unity easy saving, unity easy save tutorials, unity saving tutorial, unity player prefs tutorial, unity easy save, unity easysave, easy save 2, easysave 2 unity, unity easy save gameobject, unity3d easysave 2, ES2 unity tutorial, ES2 unity, unity loading data, unity saving data, unity saving system, unity loading system, brackeys, tarodev, codemonkey, unity, unity3d, unity tutorial, indie dev, gamedev
Id: UMpGJuf6h24
Channel Id: undefined
Length: 25min 28sec (1528 seconds)
Published: Sat Jul 09 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.