How To Save And Load Options And Graphics Settings - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another i've mentioned full tutorial and in today's video we'll be continuing on with our series of creating a main menu and an options menu today what we're doing is saving and loading our options menu which we have set up in a previous video now i'm going to go right ahead and start with this and if you haven't already seen the previous videos i definitely recommend going to watching those now as that's where we actually set up the menu and actually changing the options settings and graphic settings and what stuff as well so again without further ado let me get right into this one and we're going to start off by opening up our options menu which we created last time so for me that's options menu here this is what we've got and we're going to go over to the event graph here again this is what we set up previously to actually change all of the graphic settings as you can see here so now the first thing i want to do is i want to actually save our settings so to do that we can go back to our designer and we want to create a new button so we press this button to save so what i'm going to do is duplicate my back button as it's basically going to be the same thing so select it hit ctrl c select the canvas panel hit control v now i'm going to move this back button all the way to the bottom right so let me get it to the same level and then i'm going to move it to the bottom right as that's just where i want to have it so it's next to the optimal settings over here and here we are this is roughly where i want it to be i'm also going to change my anchor to be in the bottom right like so and you can obviously move it about to make it look a bit better for you but this is how i want it i'm going to rename it from back button to save button and also change the text on there to be save as well so the player knows what it does so here we go save like that and we'll compile and save that now select the save button again scroll down to the bottom right and get the on clicked event so this is where we can now actually do the saving code i'm going to move it up here just so it's going up near the top as well i'm going to move it all the way up here actually and so now the saving code is very simple what we're going to do is simply come out of this and get game user settings and our return value save settings nice and simple like that that is all we need to do this is again why i love using the game user settings is because all of it is already just done and set up for us now what i will mention is if you do have your own different options which aren't in the game user settings then you will want to create a save game and set up saving that way which i do have other videos going over as well if that's what you wanted but what we've done is just use the game user settings so this is all we need to do what i'm also going to do is right click add a custom event naming this save settings connecting that into the game user settings there and we'll compile and save that now i'm probably not going to actually be using that during this video or in this series but i always like to do anyway just in case i do want to save these settings externally either player doesn't click on the button but i want to make sure it's saved anyway this is why i always have a custom event so we can call this as well that's just right i'm doing that i'm going to select this all press c to comment it naming this save settings and the low settings is just as simple as this so what we're going to do is we don't want the player to press the button to load the settings we just want to load the settings when they start the game so we're going to be doing this just via a custom event so i'm going to go over to the right to get some space right click add a custom event naming this load settings like so so now this once again we're going to get game user settings and the return value will simply be apply settings because we don't want to load we just want to apply them so when we save it we're saving it to the game's settings so when we get it this here is technically loading the settings and we want to then get those settings and just apply them and as we did before we want to untick check for command line overrides so this here is going to be loading and applying the settings however what we also mentioned in the previous videos was that what we've done is when we press a button it's going to actually select it so the player knows which one is selected i also want to load this so when the player opens the options again for another time it's going to have loaded their selected options so they know which ones are currently active and this is also just as simple just a bit more lengthy and a bit more repetitive as was the other videos so what we want to do first is we go to the designer what we'll see is we're going to do the display resolution first so what we need to do is make sure we have in this drop down box here which one the players got selected so that's quite simple what we're going to do is drag out the return value of the get game user settings and get screen resolution we're going to come out the return value of that and break int point so we now have it in the x and y values then we're going to get a two text integer for both of these so both of the x and the y leaving it just as normal and default like so then this is going to go into a format text so right click and get format text in the format we're going to write open brackets x close brackets x open brackets y close brackets and the brackets are the ones with a little indent on them i'll have them on screen so you can actually see which ones i mean and then the x to text goes into x and the y goes into y so this is going to write our x value x and our y value so ie 1920 x 1080 then we want to just simply put this into our drop down box so on the left if we find our combo box string drag that in get it out of this we're going to set selected option make sure it's selected option not selected index connect that into the apply settings so it fires off after it and then the option is simply going to be the result of our format text so drag that into there and it should automatically convert it into a string so now that's going to get the screen resolution and type it on screen so the player can actually read it as you can see here i'll compile and save that now we're going to move on to selecting the buttons so what we're going to do is hold down s left click to get to sequence after this so we can fire off a lot of code all one after another instead of doing one big line we can have it going up and down just keep it nice and neat and organized so we're going to drag off of then zero and go all the way up here because we're gonna need a lot of space for this and we're going to get game user settings it's just easier to have up here rather than the way down here and dragging over you can obviously promote it to a variable if you want to but this is going to be just as simple for us we're going to be starting off with the frame rate limit as this is going to be the most lengthy one to do so out of the retar value we're going to get frame rate limit as you can see there and we're going to truncate this value so it turns it into an integer like so so truncate if i spell it correctly that would help truncate so it goes from a float to an integer because we don't need it to be 30.00 we just need to be 30 or 60 or whatever it is which you set it to it's going to move that down like so then we just want to see what the value actually is based upon different values we have inputted so after the return value i'm going to drag and get an equal equal integer the lowest the player can set it to for me is going to be 30. so again if we go to the designer we can see we have 30 60 120 and unlimited unlimited obviously being zero that it's setting it to so firstly i've got 30 here we want to see if it is being set to 30 so we're going to hold down b left click to get a branch with that being the condition connecting into the game user settings and true means the player has selected 30 fps as their frame rate limit so we want to get our function of select fps button connecting that into true and setting this to be 30fps because again this is how we're actually selecting our buttons if it's not 30 we want to see if it's the next long which would be 60. so hold down b left click to go branch connecting that into false of the first branch the condition for this is going to be another equal equal integer so you can just duplicate that there connecting into the truncate again this time being a value of 60. i'm going to just straighten that to keep it organized i'll move up just to max my space then again select fps button function this one being 60 instead of 30. then we'll do this again so i'm going to copy all of these so the equal equal branch and function control c control v connecting it into false there this one into truncate and the value this time being 120 then obviously 120 there copy and paste one final time into false into the truncate and this one is going to be equal to zero because for me the last one is unlimited which is obviously zero so i hope that makes sense as to why we've just done what we've done we're seeing what the current fps value is for the player and then just selecting the button based upon that i'm going to again move these close together just to max my space and then i'm going to move these up like so now the next ones we do are going to be a lot more simple than this the only reason we have to do this is because the frame rate limit is a bit more tricky as there's lots of different values whereas the other ones it's going to be a value of 0 1 2 or 3 so we can actually do a switch on end to keep that looking nice and organized later on so we'll compile save that's now the fps done and as again we've done this on the load so every time we load the settings it's also going to load the buttons so let's now move on to the next options which for me is going to be the view distance so we'll come out of then one and get game user settings moving that up here i'm just going to do it in rough places and then move it later on once i finished it all after the return value we're going to get view distance quality retirement of that will be a switch on int so it's going to fire off a different execution pin based upon an integer which we input so again for me it's going to be either 0 1 2 or 3. so again if i go to the designer near zero medium is one fire is two epic is three you'll know all this if you've watched the previous video so we have four different values so we're going to add four pins we've got zero one two and three and if we want we can also right click and remove execution pin for the default because we're not going to need it so as you may have guessed obviously depending on what the value is we're going to change our function to select a different button so if we select view distance button connecting that into 0 that's going to be near connecting it into one is going to be medium connecting it into two it's going to be far and connecting it into three it's going to be epic very simple and again that's all we need to do for that one i told you it'd be a lot easier than doing the fps let's get that one was just a tricky one that we had to do so i'm gonna move this down a tiny bit like so and really all of them now are just the same process that we have here so i'm gonna do is select all this control c control v to put it down here and then connect this into another execution pin of then two dragging that into there and all we need to do is just change it from get view distance to instead get post processing quality i believe it's the next one delete that input enter there and then all we need to do now is actually just change over these functions as well but obviously everything else is the same it's just the functions so it will delete these functions and we don't need to copy them next time do we although it was good to keep it aligned so what we're going to do is select this processing button being low connecting it to zero then just duplicate this again and then just change it to what needs to be ie medium then high then epic so as it has been with the other videos this is going to be a repetitive process but i'm going to be showing you all anyway just so you know what you're doing and so you don't get lost in anything but again this is really the bad thing about options menus is they are very repetitive and i might just give that bit more space in between them copy and paste down here and the reason i'm doing the functions as well is just so i get the spacing all set up here like so then this one is going to go into another execution pin on the sequence changing it from get post processing to see up here get anti aliasing quality connecting it into there like so and changing over the functions once again one final time zero is low copy and paste one is medium copy and paste two is high copy and paste and three is epic simple as that then we'll copy and paste all of this once again moving it down here into another execution pin on the sequence this time it's not post processing and to any listing sorry it is now the texture quality so we'll put that into the section there changing over these functions so delete these move it down low medium high and epic as we have here for the text quality so again what this is doing inside of our function is just disabling and enabling different buttons so the player knows visually which one is actually selected for their current options menu for their current option and we'll duplicate this one final time for the shadow quality now so one more execution pin connecting into there changing text quality to shadow quality and then we do have another one to do after this however is going to be different which again i'll obviously show you the text quality is now shadow quality but again everything else is the same is going to be low medium high and epic with being 0 1 2 and 3. so i've now got that done there so there is one final thing left to do and that is the window mode now this is gonna be slightly different there's only two buttons and two options which we have however we're doing it slightly differently and also very efficiently so add another execute pin on here drag all the way down out of it down here and again get game user settings like so and it will go down here and after the return value we're going to get full screen mode that's what it's actually called not window mode but full screen mode and you'll notice the entirety of this isn't a float or an integer it is actually an enum so it's in a numerator so we drag out of this and we can still get a switch this time being a switch on e window mode connecting that into there and with this you'll notice again we have full screen windowed full screen and windowed all we used is full screen and windowed so very simply same thing again select window mode function this one being full screen and this one being windowed nice and simply done like so we'll compile and save that and this is now these loading and saving of our options completely done and set up i'm just going to move this a bit here just keep it a bit more organized and then select all hit c to comment it naming this load options so again this looks like it's quite a lot but this here really is all we need for loading the options everything else is just visually allowing the player to see which option they have selected so it's selecting the buttons so we'll compile and save that and one final thing what we can also do is when we set the optional settings the optimal settings sorry down here instead of pressing apply hardware benchmark what we can do is simply save settings so let me call the function instead call function save settings and then call function apply settings or not apply sorry load settings and what this will do is it will now also visually display which options have been set by using these here so before the player couldn't see what the optimal settings were now they actually can so we'll compile and save that now we actually need to call this load settings button so what we're going to do is close this all we need to do is open up our main menu widget go to the graph and we're going to change how we open the options menu slightly so what we're going to do is get event construct up at the top here and out of this we're going to create widget with the class being our options menu and out of the recovery of this we are going to promote it to available naming this options menu and out of this we're going to then not add viewport but instead load settings so call the function which we just created so when we open the main menu i open the game it's also going to load the settings now if we go back down to our options menu here instead of creating the widget once again all we want to do is just get the options menu variable we've created and add that to the viewport instead so we don't need to continue to create it we're just adding it there and we'll compile and save that we're going to close this and now we're going to test out if i open up my main menu level we can hit play to see if this works so it should have then loaded my settings which i saved previously give it a second to load there we go so you'll notice we're now full screen as that's what i had it to previously if we go to the options back options back you'll notice that still works even though we changed how we're putting on screen if we go to the options you can see these are settings which i've got selected now the resolution is 1280 by 720 but i've set it to full screen so let's also change this to 90 20 by 1080 as well let's put it to 30 fps and everything on the lowest possible settings save that back let's start the game just to make sure it has done that it has this looks terrible so it's all for that and then restart just to see if that did actually save and load our settings so if we go back in it's now full screen 1920 by 1080 as that's what we set it to be it's loaded that goes to the options 30 fps everything was on the lowest settings and if we press start you'll notice this looks the exact same so this now works perfectly for us what we've done is you set up an options menu in which we can save and load the settings once we have changed it and that is also based on actually changing the values themselves and also the selection button as you can see here so the player can also see what they have changed so i'm going to save that once again so thanks so much for watching this video i hope you enjoyed it and i hope you did find it helpful and if you did make sure to like and subscribe down below so thanks so much for watching and i'll see in the next one [Music]
Info
Channel: Matt Aspland
Views: 31,895
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, ue5, unreal engine 5, view distance, post processing, texture, quality, shadow, shadow quality, frame rate, limit, fps, windowed, fullscreen, resolution, ue4 main menu, ue4 change settings, ue4 change graphics settings, change, graphics, settings, options, texures, ue4 how to, main menu, game user settings, hardware benchmark, screen, save, load, and, button, selected, option
Id: 4M2v2SYJDJk
Channel Id: undefined
Length: 19min 7sec (1147 seconds)
Published: Tue Apr 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.