Hello guys.
Welcome to the video.
In this one we're going to do cleanup.
And also we need to do a couple of things that I forgot to do.
Nothing much, nothing special.
One of them is I forgot to put on select script on other buttons such as uh, settings button and level
selection.
So this is what we need to do.
Let's go to scripts UI and we have this update last selected.
So I think we can take.
A select back, back back.
Maybe a sliders as well.
Should be those sliders.
Let's do sliders as well.
So sliders back button on skin selection and select button on skin selection.
Also back button on level selection.
And let's just drag this update last selected like that.
This is supposed to work.
Um, there is also a level button.
I'm not sure if we need to put it on a level button, but wait, let me find my gamepad.
I want to test this.
All right.
So I'm going to go to prefab uh UI level button.
Let's add here.
UI update last selected.
Okay.
Now this is supposed to work.
I'm going to go to play mode.
New game normal select.
There are levels so third one is selected.
I'm going to click my mouse and level was deselected I mean button.
Then I'm going to use my navigation on a gamepad again.
And we have selected button okay I think it's worth to keep it.
So that's one thing I forgot to do to put the scripts on other buttons in the UI.
If you want to add this to in game, you can do that as well.
Just take resume button and menu button and add component of update last selected.
Oh no no no don't do that because.
Because it doesn't have main menu.
Right?
But what happens if we do it?
What happens if we click mouse in the game?
Let me check that.
I'm sorry, I forgot about this one.
There were so many things to do in the last video.
Level two.
Okay, I'm going to press escape.
I can click buttons.
I'm going to use my mouse.
It is deselected and now I cannot select anything again okay.
So that's the problem.
Now let's quickly fix it.
I'm going to go to scene level one.
UI in game.
Let's open the script.
And over here we just need a method that would update current selected button.
And we have this on the main menu.
We have a method like that just this one.
So I'm going to copy this method.
Let's go to UI in game I want to do close.
All by this I'm going to paste this method somewhere below update.
And instead of last selected, let's use first selected because there is only two buttons in the pose
UI, so it's okay I guess.
Then we need to go here and do player input.
UI navigation performed plus SQL CX update.
Update selected.
Now let's duplicate this.
Move this below and do minus.
All right.
This is super good.
I like it.
Now let's go and try this.
I'm going to go to play mode.
I'll use my keyboard.
Escape can click the buttons using my mouse cannot click the buttons.
Now I'm going to click buttons again on the keyboard and I can select something with a keyboard.
Okay.
So you can switch between devices.
Works good.
Now let's go ahead.
Clear it and let's go to Asset scene main menu.
And there is something else I forgot to do.
As of now, if we go to new game.
And we are choosing the difficulty.
This showing the difficulty.
But if you use your keyboard it does not show the difficulty.
So we need to fix that.
We need to go to canvas.
Let's find difficulty buttons.
There they are.
And we need to add.
I unselect, I select handler and I deselect handler.
Let's implement this interface.
Or deselect and for select.
All right.
This is good.
Now they placed in a weird order, but it's okay.
So when we deselect, we just need to make text empty.
And when we select, we need to give it a description like that.
Okay.
How could we arrange it better?
Now let's take this.
And place it over here like that.
And pointer enter and pointer exit on select on deselect.
Okay, good.
And this is supposed to help it.
I'm going to double check this.
New game.
Yeah.
Okay.
Nice works with the keyboard and mouse.
Something else there we have this functionality on the main menu.
I'm not the main menu on skin selection.
I'm sorry.
Over here.
And we do not unsubscribe from this.
It's always better to unsubscribe from the event.
So let's make a method for this so we can unsubscribe from the event.
I'm going to do private void.
Switch skin.
With, um, navigation like that, we need to pass input action callback context CTCs.
And inside we're going to just do this functionality.
So I'm going to cut it out and paste it in here.
And then instead of curly brackets, we're going to do switch screen with navigation.
And we're going to pass it ctcss just like that.
Now let's duplicate this, move this below and let's do minus over here.
So this is just a bit of a cleanup that.
It needs to be done right.
This is the end result.
Take a look, write it down.
And I think that's all what came to my mind regarding the clean up.
I don't remember anything else.
If something comes up, I'll let you know.
Maybe I can update the video later.
As of now, this is pretty good.
I think we are ready to jump to the next section.
We did a lot of good work here and it took not that much of a time, right?
Yeah.
All right.
I'm going to drop this project into archive.
I'm going to give it to you and I'll.
Oh.
Hey, guys.
Sorry, I forgot to show you something else here on this table over here.
We need to do on disable, and we need to do default input disable and default input.
Uh, UI navigate performed SQL syntax update selected.
Yeah, I guess now that's it.
All right.
See you.