 Hello, everyone. It is CryptoGround here. Welcome back to another Unity Idle Game Tutorial video, this episode 5.0. And today we're going to be starting the notation system. We're not going to be actually making any notations today. They'll be in the future episodes, but we're going to get everything set up. Be sure to leave a like and subscribe if you're new around here. And let's just hop right into it. So for the first part of this video, we're going to be inside of our methods script. So let's head there real quick. Inside of this class, we only have one method, which is the upgrade check. I forgot to do this earlier, but we can actually get rid of this mono behavior. And the reason why is because we're not going to be using anything related to Unity Engine inside here. And our script isn't going to go into the hierarchy. Since we got rid of that we want to make this class a static class because we're going to be using this in other scripts without having to initialize it as an object. Okay, now let's make this notation method. I'm going to be creating the structure today. And we will actually be creating more stuff in the future. Since we're going to be returning a formatted string or a number, we're going to be returning a string. So this will be a static string method. And I'm going to just call it notate, we're not going to be returning anything yet. So we're just going to return an empty string for now, just to get rid of the errors. Next, I'm going to create a static int variable. And this will be used for our settings to actually determine which notation we are currently looking at because we're going to have more than one. This can fit as many notations as you like. So this is useful if you want to make your own. Next, what I'm going to create is a switch statements. And we're not going to really do anything in here because we don't have like the actual notation setup. But this is where we're going to determine which one we're going to use. So for example, zero is going to be our standard notation. That's going to be the next video episode 5.1. And I'm just going to return an empty string because we're not going to be really doing anything actually, I'll just return a funny string, just so we can actually see it in action. And then case one will be scientific, for example, and you just keep incrementing this number for every notation you add. Okay, so now we know how to determine which notation we're going to use. So what I do in idle research is don't show any notation until we hit a million. So we're going to eventually do this. But for now, I'm just going to place a temporary comment just to remind us that we're going to do this once we have our standard notation. So we have our notation method that we're going to be using later on. So now let's create the setting script so we can change this notation variable. Before we actually create the script, I'd like to show you guys what I've done so far. So I have separated the save settings and the main settings. So now there's two buttons. So we're going to actually have to do this inside the code as well. If you want to have different tabs like these, make sure you add these buttons as well. And just so you're on the same pace as I am. I have added a notation setting inside of a game object with a grid layout group. I turn this off temporarily. So that if I wanted to add new settings, I could just copy add some more upgrades, turn this on, turn this off. And the reason why I turn it off is because it's kind of has a lot of CPU usage. So it's safe to just to turn it off when you really don't need to use it every single frame. I only want this on just to add more upgrades and then turn it right back off just so everything looks right. So if I need to adjust this, okay, I'm just turn it back on, add some spacing, just like that. I think that looks fine. Like that. And then I can turn it right back off. And it's good to go. But but we really only need this one button, which is the notation, and it's going to display notation, and then whatever one we're using. So standard would be the default. And that's all we need to do. All right, so let's create the script. So I have created this setting script to open it up. So we don't really need any of this. So just clean it up and start fresh. We need to include the TM pro namespace. Let's make our first method. And this will be our start method. And we're just going to call this start settings, just like the upgrades manager, we're going to be calling this inside the controller script. Next, let's create a single 10. Okay, so we have our single 10. Now let's call this method inside controller. Let's head to our start method. And at the very bottom, let's call settings dot instance dot start settings. Next, let's head back to our setting script. And inside of our start method, we want to set our notation to a value. So for now, I'm just going to set it to zero. So that will be methods dot notation equals zero, we need to create a variable instead of our data class. So we can load it. So let's head to our data class. And inside of this data class, let's create an integer. And inside the constructor, we're going to set notation to zero. So this will be standard notation by default back to settings. And now we can set our methods dot notation equal to controller dot instance dot data dot notation. Now a little advice, I should have done this earlier. But the single 10s actually don't need to be renamed as instance that can be named whatever you want. So if you want to clean your code up, what you can do, this is a writer feature, I'm not sure if you can do this on Visual Studio or any other IDE, but we can do is rename this variable. So instead of instance, I'm gonna set it to lowercase controller. What this will do is that it's going to rename it. Okay, good. And then what we can do is import static members. So basically, we can add using static controller at the top. So then we only have to do controller dot data notation, and it's going to work exactly the same thing. It's the same with settings. We can actually go to our controller script, go down here, rename the instance variable of settings, and by going to refactor. And basically this refactor is going to look for this all over the code. And it's gonna rename every single one of them instead of having to do it one by one. So that's kind of a nice thing. So I can just name this lowercase settings. Next, okay, import static members, which, again, it's just the using static settings at the very top. And you can do the same thing for upgrades manager. So I'm going to do that real quick. So I'm going to do upgrades lowercase, you and manager capital M, and then import static members. So how I got this is all enter. Now, again, you may not be able to do this in Visual Studio. But we also try to do is to right click on this and do refactor rename. And you'll also see the show context actions on Visual Studio. Maybe again, I'm just guessing, you'll just be able to go to refactor, rename and go from there. So you can do that for every single script. And that's really neat. So back to our setting script, what we can also do is import the static reference of methods. So then we don't have to use methods dot and then the variable. So we can just get rid of methods. And we're good. So we can just set notation to controller dot data dot notation. Now this only works if we don't have a variable in here called notation already. Otherwise, it's just going to refer to this one here. And then the one in methods is going to be ignored. In that case, that's when you need to do methods dot notation. Hopefully that makes sense. It's a bit complex. But if you need to watch that a few times, go ahead. All right, so let's make another method that actually changes the notation setting, it will take in a string parameter, I'm going to call it setting name. And I'm also going to make another method called sync setting. So we're going to change the UI in here. So instead of calling it every frame in the update method, we're just going to change it whenever we load the game, or whenever we actually change a setting. And this parameter that we're going to throw in, which is setting name to string, it's going to be optional. So we're going to set it to an empty string. And if we don't pass in a string at all, we're just going to assume that we want to update all of the strings in here, or all of the text, we're going to want to call this inside our start method. We're also going to want to call that in change setting, but instead we're going to pass in our setting name. So now we actually want to update whatever we changed. Okay, so let's make this switch statement in here. And we're going to put in our setting name as the parameter. And for the first case, it's just going to be notation, very simple. And we're going to break it just because we're not going to do anything yet, because I want to explain what we're going to do. What we're going to do is cycle between the notation. So we're going to, let's say we have two notations, we're basically going to alternate between zero and one. If we have three notations, it'll be zero, one, two, and repeat. Okay, so let's do this. I'm going to create a string array that has all of our names like all the notation names inside of them. And we're going to go off of that. So I call this notation names. And inside of our start settings, I'm going to initialize this array. And for the first notation, it's going to be standard. And then the next one will be scientific. Okay, so we have two things in here. So we basically want to alternate between zero and one. And we're going to do this by using the length variable inside of this array. So I'm going to do controller dot data dot notation. And I'm going to increment it by one. And if this notation is greater than how many things we have in here, we're going to set it back to zero. And it's actually going to be minus one. So if our notation is greater than one, so that would be our notation names dot length because we have two things. So length minus one. Then we're going to set our notation back to zero. And things are getting pretty length in here. So I'm going to make a local variable for data. And now I'm just going to refactor. Okay, things look a bit cleaner. So now we actually change this notation. However, we need to change the notation inside of our methods. So I'm just going to do methods notation. And if you remember, we are accessing the methods reference, as explained earlier, so we can just get rid of the methods dot and just do notation equals data dot notation. Now this will just change the notation according to the notation method that we've created. So next we want to sync the setting. And we actually want to change it. So we haven't made that setting yet. Let's do that real quick. So I have created a text much pro text array. And I call that the setting text. And we're only going to have one of these. So inside of our sync settings, we're going to be doing the same switch statements. Let me create that real quick. So inside of this notation, we're going to be changing the settings text at index zero because that's going to be the first setting. And we're going to set that to notation colon new line. And then we're going to have our notation names at index, whatever notation is so we can actually just do notation, set of data notation, convert this into string interpolation by adding the dollar sign at the beginning of the string, and then adding the curly braces at the end, putting our variable inside of those. So now what if this string was empty, like we wanted to change all of them? Well, we're going to actually have to do this manually. So let's create an if statement. So I've created this if statement. So if the setting name is equal to string dot empty. Now, this is the same thing as just an empty string. Oops, I messed that up, just an empty string like this. But however, we're not creating a brand new string every time we call this. And we're kind of saving some memory by just using a preexisting object, which is just an empty string. And we actually can't do this in here, because this is an object. So we can't put anything in here. That's an object. Anyway, so if this is true, we're going to update all of our texts accordingly. So we only have our notation one, and then we're going to return this method. Otherwise, if it's not empty, we're going to be using the switch statement to determine which one we want to change. Okay, so I want to show you an example real quick. Let's head back to our methods. Currently, this method is not usable in the way it should be. We're going to be doing something very special. We're going to be assigning this method to a big double. So how do we do that? So so we use that this term, and then a big double if you're using big doubles, and then just a variable name. So we're just going to put number. So basically, this allows us to attach this method to any big double variable. So I'll show you an example. Let's head to controller. And let's head to our updates. And let's mess with our data flash real quick. So I'm going to delete this colon F2 and replace it with dot notate. So you see we're accessing the methods dot notate method, which is in here, and that belongs to a big double. So now what it's going to return instead of displaying the flash, by default, it's going to say lol. Okay, and then if we were to change it, it's just going to say science if we change the setting. So that is all we need to do in the code. Now let's get back to Unity. Okay, so in Unity, we want to assign this change setting. So we actually don't have a setting script yet. So let's create that. I'm going to right click on our scripts, empty game object, create empty, call that settings and assign our settings script to this. Let's drag this text for our notation setting into the settings array. And let's head to our notation upgrade our button. And we want to assign that change method. So I'm going to do that. And we want to put notation because we go into our settings script. And as you can see, we're checking for notation for this button. So that is all we need to do for the notation part, but we still actually need to make these two buttons do something. So I'll do that after we test this out. So as you can see, it says lol. If we go to settings and change the notation to scientific, it's just going to say science. And yeah, so it works beautifully. We will actually make notations in the next few episodes. Now let's make the save and main settings buttons actually do something. So I have created a game object array called setting panels. And this will be our safe settings and our main settings. So let's mess with that. So let's create a public void method. And this will be our navigate settings. We want to take in another string parameter. And by default, we're going to loop through all of the game objects. So this is our for loop. And in every single panel, we're going to turn them off. So dot set active false. And what we can actually do is convert this into a for each. So it's basically just going to go through every single game object inside of this array. And we're going to turn it to false. And I'm just going to rename these to panel just so it's more clear. Next, we want to create a switch statement. And it's going to take in location. And for the first one, we're going to have our save settings. So I'm just going to put save. And since the save will be first setting panels at index zero will be true. We're going to break that. We'll be changing the first index for our main settings. That is all we need to do for this method. So in the setting script, I'm going to assign our save settings panel and our main settings panel. And next, I'm going to assign both of these buttons to the proper methods. So the saving will be save. And main will be main. Let's give us a shot. Save main, save main. So sweet. We can now switch between these two settings. You can add as many tabs as you like. I hope you guys enjoyed this video. And if you learned something new, make sure you please leave like as it really helps out the videos. Consider subscribing if you are new around here and you haven't seen any of my videos before or if you aren't subscribed already. It's a mistake. And if you tend to miss out on my videos and you don't have the notifications turned on, make sure you click that bell so you get notified. I try my best to livestream as much as possible as well. I like to work on my games on stream. So if you're interested in that, make sure you turn on notifications. If you're interested in beta testing my games or if you just want to support the channel, check out the Patreon description below or become a YouTube member today. Thank you very much for watching and I hope you guys have a great day or night. I'll see you in episode 5.1, which will be standard notation. I'll catch you in the next one. Peace.