 In this very easy episode, I'm going to be teaching you guys how to merge your click and production upgrade panels into one using buttons like that. Well, hello everyone. It is Crypto Grounds here. Welcome back to another Unity Idle Game Tutorial video this episode 3.1. And today I'm going to be merging these two upgrade panels into one just so we have less panels to view at a time. So yeah, this is a pretty easy process. We're going to basically just have two buttons that are going to switch between the click and the production upgrades. And you can always add more if you'd like. So first off, I'm going to create the UI real quick. One thing that I actually just learned recently that I have no idea how I missed this in the past. But for the scroll bar, we don't need to rotate this. So it normally looks like this. But what we can do is go to our scroll bar component and we can change the direction from left to right can do bottom to top or top to bottom. So if we do top to bottom, it will automatically rotate and it will adjust where you want to scroll. So it'll go from top to bottom instead of left to right. So you don't have to do any of that rotate things. And what you can do now is have it stretch with this panel to the side so you can go to the record transform, select the right stretch. And now if you adjust the resolution, it will stretch accordingly, which is nice. I don't know how I missed this, but it was definitely a lifesaver. And yeah, so hopefully that was helpful. Okay, so what I've done is that I have created our two tabs here. I decided to go for a more simplistic thing here. And it looks a little better. But so I have added these two buttons and a scroll bar. As you can see, I changed it to top to bottom. And for the buttons, I have a button just with no image or anything. And inside of that, I have a selected image looks like that. Also, I need to get rid of this button inside the selected. So it's just an image in the selected. And then there's the title. So I added the selected to determine which one was selected and it just looks better. So if this one was selected, the text would turn white and the image would turn on, which we will do that in the code later. So now we need to merge our two previous scrolls. So what we can do is take this production upgrade scroll. And we are going to throw it inside of this click upgrades and we're just going to rename this whole thing to upgrade lists. What we're going to do is resize our click upgrades, our scrolls here to the proper size. So here we have our click upgrade scrolls and it looks like that. So I'm going to move this one over here as well. I'm going to make sure it's lined up with the other one. Okay, now we can delete this old production upgrades and we can eventually use this for something else, maybe a navigation system. So now we have the system ready to go. We're going to head into our new script. So I'm going to create an empty game object and I'm going to call this navigation. And in our scripts, I'm going to create a brand new script called navigation. So in this class, this is we're going to manage everything related to navigation. So this is if we make a navigation panel to access other things, or if we just want to switch between our upgrades here, we're going to do it inside the navigation just because everything will kind of work similarly. So I'd rather just be consistent and keep everything in one place. So we don't need the void starts and update method. Get rid of that. What we will need is our two scrolls and we need our upgrade tabs. Now for the scrolls, you could access them from upgrade manager or you can just create two more instances in here. That is up to you. I am just going to access them from upgrade manager. So in that case, all we need to do is access our click upgrade button. We need access are selected and our title. So I'm going to throw in an image and make sure you import the unity engine.ui. And I'm just going to call this the click upgrade selected. I'm going to do the exact same thing for production upgrades. And now we need to throw in our text and we are using TMP text. So don't forget to import TMPro namespace. And this will just be called the click upgrades title text, whatever you want. Same thing for production. Now I'm going to create a brand new public void method. And this will be called switch upgrades for our parameter. We're going to make a string and it's going to call the location. And in here we're going to be using a switch case. So switch location and for our first case, it will be click. And in click, we're going to grab this click upgrades selected. We're going to do that game object dot set active. And actually we can make this into a game object because we're not changing the color of these or anything or any of its image property. So we can just make this a game objects. Now in that case, we can get rid of this dot game object because we are accessing the game object directly. So we can just do click upgrades selected dot set active. And for our click upgrades title, we are going to switch between the gray and the white. And we're going to set the color of this text to color dot white. And we're going to break it and we're going to do the exact same thing for production. Okay, so now we can change these. We need to make sure they turn off. So in that case, what we're going to do is just do click upgrades dot set active false and also production upgrades dot set active false. And for our text, we're going to set both of them to gray. So that would be our text dot color color dot gray. And I'm going to do the same thing for our production upgrades. So now whatever we are going to, we're going to set them to true. We're going to turn them on and change the color of the text to white. So now we have to switch upgrades thing, but we actually still have to switch the production upgrade scroll and the click one. So what we can do in here is also access our upgrade manager and odd instance. We're going to access a click upgrade scroll. And we're going to do game object dot set active. And since it's a scroll wrecked and not a game object, we must put this dot game object. And we're going to set that to false. Do the exact same thing for the production upgrades. And in each, we're going to set these to true. Great. So now we can switch between the click and the production upgrade. So let's give this a try. All right. In unity, we need to assign our two buttons. So the first one click and production would be the second one. So I'm going to go to our button component. I'm going to drag in our navigation script and select no function. Okay. So we actually haven't assigned our script yet. So go to add component in your empty game object for navigation and add the navigation. So we're going to add our selected and our title text. So we have a selected, selected title and title. Now for our buttons, we can assign our method to switch upgrades. So remember, our first one is click and then production. So our click upgrades button, we're going to type in the click string and the second one will be production. And I'm going to disable the production scroll and let's hit it. Okay. So we have our click scroll here and the progress bar seems to be working just fine. This actually seems flipped. So I'm not to flip it from bottom to top. My apologies and production. We're switching between the click and production. So that is very nice. Let me just flip that scroll bar from bottom to top. And now it should look fine. Yep. There we go. That is better. Anyways, guys, I hope this video was helpful. And if you guys enjoyed this video, it makes you leave a like, subscribe to my channel if you're new and turn on the bell for future notifications and live streams. If you want to support me, consider checking out the Patreon below or hit that join button. So I'm very sorry that I've been very terrible of uploads lately. I just went on a 10 day vacation. So it was very nice. I feel much better. But yeah, so I'll see you guys in the next one in episode 3.2. And that will be the upgrade unlock system. So basically what's going to happen is that you're going to have some hidden upgrades until you reach a certain point and you can unlock them or they will just magically appear. So that is pretty much an optional video. But if you guys are into that, make sure you look out for the next one. Anyways, thank you guys for watching and have a great day and night. I'll see you in the next one. Peace.