Hello guys.
Welcome to the video.
So in this one we're going to make a build for mobile.
It's going to be not that difficult to do actually just takes lots of time to switch the project to
the mobile version.
So what we need to do here, um, maybe make a copy of your project just in case I did.
You can see here I did a copy, but, uh, if you make a mistake, don't worry.
You can always get my project from the course.
Now let's go to file.
Uh, build profiles.
And over here, we need to switch to Android.
As you can see, I can switch profile right now because I did download the Android before, but, uh,
for you, you would have to download it from the beginning.
Also, I want to show you how to do that, although it's just an install button.
Um, let me check.
Maybe there is a new unity version.
I can get it.
And then I'm going to show you.
Yeah, there is a new editor point seven.
Okay, I'm going to install this one.
Then I'm going to come back to you and show you how to download things that we need for Android build.
All right, so I've got a bit later unity version over here.
We need to choose Android.
And you can see it says no Android module loaded.
So we need to click install with Unity Hub.
Let's do it.
It's going to open Unity Hub and it's going to offer you to install Android, build support, JDK and
so on.
And that's what we need to do.
So I'm going to do continue agree install.
Now I'll have to wait.
So I'll get back to you when it's done okay.
It's done.
Now I need to restart the unity.
I'm going to do it real quick.
All right.
I did restart unity with a new version.
Looks a bit different, but just a color I guess.
And maybe a couple of buttons, but overall it's all the same, so nothing to worry about.
Now let's get back to the thing we did.
We were trying to switch platform to Android and that's what we need to do.
I'm going to click Switch Platform and it will take a while, but not that long to switch it.
Okay.
Very good.
Half job is done.
Now, there are some things we need to do to make a build.
But before we build anything, let's go to window.
Package manager.
And over here in unity registry, we need to type device.
Over here we have device simulator device and we need to install this one.
So this one allows you to simulate the mobile phone inside of unity.
We need this so we can test some major things without uploading game to the phone.
Because if you want to test something on the phone, you need to make a build.
You need to send apk file to your phone, install it on the phone, then launch the game, then see
what you need to test and that is okay if you want to do it once or twice.
But if you need to test many things, that can be quite time consuming.
That's why we're going to use this device simulator device, which has a really weird name, but doesn't
matter.
The main point?
It works.
Yes, it will help us to test some, uh, important things before we make any build.
And also, it will help you to test your game on different devices.
So first of all, let's go to free aspect do 1920 by 1080 landscape.
And then let's go to window.
And general device simulator.
And we're going to drag it over here.
So this one allows you to simulate, uh.
Phone or iPad in this window.
We're gonna rotate it.
Uh.
Wait.
I'm not sure about iPad five.
I never had it.
Let's change to something.
I know you can see there are some later devices like iPhone 13 Pro Max.
I personally I don't have any iPhone or MacBook.
So I don't know how to work with them.
I'm going to choose.
Samsung Galaxy.
Let me see one second.
Yeah, I'm going to use Samsung Galaxy S10 plus.
That's the closest version to the one I have.
All right.
And we're going to rotate it like so.
So now we can imagine that we have a phone device instead of unity when we hit the play button.
Yeah.
Very well.
Oh, wait, I'm sorry.
We need to go to simulator and change to play focused.
Now let's go to play mode.
And.
Hmm.
Let's change here.
Wait supposed to do lay focused.
Okay.
And this one play unfocused just in case.
Supposed to run game here in this window.
Let's go now.
All right.
So now this how game would look on the phone.
And even now before we test game on the actual phone, we can see there are some spaces over here that
we need to fix.
And also we can see on this device I don't see amount of fruits because it has camera in the corner.
Now we can easily fix it.
I'm going to show you a couple of ways to make it work better.
You just need to understand something before we do anything else.
There are so many phones, so many devices that people could use that I think it's nearly impossible
to adjust your game for each device, especially if you are a solo developer.
If you have a big company, you can hire a team and they will, uh, adapt your game for each device
there is on the market.
But for me as a solo developer and I guess for you as well, it's a very huge task.
So what we're going to do here is sort of, uh, minimum damage control.
You know, we're going to we're going to focus on major issues.
We're going to fix as much as we can.
But I'm not going to bother myself too much with each device there are on the market.
All right.
So first of all, uh, we can see here our blue areas.
And that's going to happen on a couple of levels.
That also depends on your level design.
And I'm going to show you what we're going to do to fix this problem.
One of the fixes could be just to go to camera, main camera, find the background color.
We're going to take the color picker and choose this dark blue color that we have for background.
And now any area outside of the level will have same color as tiles on the tile set, right?
So it's less noticeable.
But I think a better solution would be just to draw levels in a much wider area.
So.
We could take.
This brush.
Sorry.
Draw it like so.
Yeah.
And.
I'm going to show you example on one level.
But you know, if you want to do these changes for other levels, you just have to do it for other levels
as well.
So now I have a big area around my level, and even if camera will catch some areas outside of the level,
it won't be noticeable because.
Because we just have something there.
Okay, so this is better now this looks like a proper level, I like it.
Another thing to discuss is this area over here and that can be fixed with a safe area.
If you click over here you can see safe area under device.
In the in case of this device.
This is the safe area inside of this shape, and we can remove rendering of the game outside of the
safe area.
We just need to go to file build profiles.
Uh player settings.
We need to open resolution and presentation and uncheck this mark render outside safe area.
This would be the safe decision to make because in that case, let's try again.
In that case, your game will be only inside of this area and you will not have anything extra.
And on the phone itself, when you play the game, this area will be pitch black.
You will not see anything, so I guess it's a safe solution.
If you don't know which device people are going to use and you don't have time to adjust screen for
all of the devices out there, probably this is the best option.
Now let's go to the scene.
Scene.
Main menu.
Save it.
And I want to check buttons over here.
First of all, I guess it would be safe to add another background area over here, so I'm going to duplicate
it.
Handle -40 on the X.
Like that.
Yeah.
And maybe.
Let's take the.
Ground and increase it here.
Okay.
Very well.
Now let's go to play mode.
These buttons are okay.
What if we go to new game?
All right.
I suspected this would happen.
Uh, I'm not sure what went wrong and when, but some of the UI buttons are messed up, so we need to
go through all of them and see them.
This back button can be attached to the central bottom line and just moved above a little bit.
Now let's go and see skin selection.
This one pretty much.
Okay, but just in case, I'll take select and back, attach them to the bottom center, move them up
a little bit, then focus on select and move it up as well.
All right.
Now let's take the settings.
Let's check it.
And back button.
Lets attach to bottom center and move up a little bit.
These elements are fine, I like them.
Level selection.
All right.
So back button bottom center move above a little bit and scroll view top center and move below a little
bit just like that.
Yeah, I think I like it.
Skin selection is fine.
Difficulty is fine.
Okay, so we did check the buttons.
Very nice.
Um.
Let me clear Playerprefs.
Nice.
Um, because I want to be sure.
Continue.
Button is not showing.
Let me double check that.
Okay for some reason.
Continue.
Button is showing.
Isn't it supposed to be switched off by default?
Continue button.
Has little progression.
Set active.
True for the definition.
So it should be switched off by default and it will be enabled if we have progress.
Okay.
Like that.
Very nice.
Now that's pretty much everything we need to do.
There are only a couple of more things I want to show you.
If we go and build the game now, it will have low FPS.
It's just just works like that and we need to fix it.
By default, VSync is enabled on the Android and also target frame rate may be not the one that you
want.
So we're going to go to main menu.
And in the wake, we need to type a couple of lines of code.
First of all, we're going to type application target frame rate equals to 60.
This will speed up your game.
I know it because I tried and it feels very slow and glitchy.
But if we do this it's going to feel, uh, fast and responsive.
Also we want to disable vsync.
So we're going to do quality settings.
VSync count equals to zero.
And we're going to do screen set resolution screen width screen height.
It will adjust the screen size according to the uh screen width and height automatically.
And also we're going to type full screen mode full screen window and then new refresh rate parenthesis.
Then we're going to open curly brackets inside of this and type here numerator equals to 60.
The numerator equals to one.
Close curly brackets and put semicolon.
So these are the things we need to type to improve performance of the game.
If you want to see the difference with and without, just do it like this first.
Then go comment this out.
Make a build again, put it on your phone and you'll see the difference.
All right.
This basically optimizes the game.
That's what you need to know.
Now, lastly, uh, we need to go to Player settings.
Let's go to file build profiles.
Player settings.
And over here we need to find rotation behavior.
Choose auto rotation.
And then we want to disable portrait and portrait upside down.
So game cannot be played vertically only horizontally.
All right.
Other things here are very specific.
And I don't suggest to change anything unless you're very sure of what you are doing.
But for us, everything will work just as it is.
So we don't really need to change anything.
You can add company name if you want, product name, version icons, all of that stuff that is up to
you.
The only thing I would suggest to do is to go to other settings and change minimum API level to 30.
This will be used later on when you make a build for play market, but I'm going to show you that in
another video.
For now we're just making a test build.
Okay, I think we can close it.
And, uh, lastly, check the scenes you have.
You go to scenes, you see how many scenes you have.
Then you go to scene list and make sure all of them are in the scene list.
And also you need to know the first scene in the list will be loaded first when you play the game.
Um.
Yeah.
Now let's go to file build profiles.
Android build.
You need to find the folder I'm going to make.
Maybe I'll just build it here.
I'm going to do platformer test.
Just like that.
I'm going to save it.
Save.
Uh, what is it?
There is an error message.
Okay.
This should not be here.
Search service.
Let's remove it.
Save it and try again.
Build.
After you're done with the build, you need to find a way to transfer this to your phone.
You can send it through Google Drive.
You can, uh, connect your phone with a wire.
I mean, with a cable like Type-C or USB, whatever you have, that's what I'm going to do.
I'm going to send this game to my phone, and then I'm going to show you how it works on my phone.
My phone is a Samsung as well.
Uh, similar to what we used to test, uh, the build in unity, but it's a bit different.
It's a bit later version, so difference is not that big.
If you have different phone, you would have to, you know, use my phone as a reference.
Use what I did as a reference and do things that I did for for your device.
Also, while we make an A build, I should say that I cannot show you how to make things for iOS, because
if you want to build something for iOS, you need a MacBook.
That's a condition.
And I don't have a MacBook, so I'm powerless here.
All right.
So we can see game is launching on my phone.
I'm going to go to new game normal.
You can select the level.
And I can run around and jump.
Everything feels responsive and nice buttons are in place.
You can see I messed up a bit in the corner of the level.
I can see blue background but that is very easy to fix.
Pause button is working.
Everything is working.
Electric.
Um.
But.
The.
I'm custom.
And just like that.
Image.
No de nada since the marriage trailer.
Patrick.
All right.
So here is the game I'm going to click new game normal mode.
Let me choose a character and level and everything works nice and pretty.
Very responsive.
I can jump around and FPS is pretty high.
Uh, we can see a bit of a give me a sec, you can see a bit of a blue area over there, but that is
very easy to fix, just about level design.
Let's try to transfer to next level and works pretty well.
Pause button is working.
Uh, let me try to jump here.
Yeah.
And we can go to main menu.
So that's what we need.
Oh also we need to resume the time scale.
We can fix that.
And let's do that now.
So possible is key.
Yeah.
Wow.
In Berlin two.
Policemen.
And I had no idea.
No, I.
The state telephone estimate.
Image.
All right.
So here is the game.
We can see nothing is rendered outside of safe area over here on the left.
And we can go to new game and choose a skin level one.
And here is the level we can see.
I messed up a bit over here we can see blue background, but that is very easy to fix and controls are
very responsive.
I like it a lot.
We can see if my character is here and I'm controlling him.
I'm covering character with my finger.
That is about level design.
I guess it's better to place level a bit like above the middle of the screen.
So you would have your finger here and your character would run here.
So now we can go to another level.
Oh let me try that.
Works fine sound is there?
Yes.
Sounds are there.
Okay.
Very nice.
Let me try to do a wall jump here.
Yeah, everything feels very responsive, I like it.
Also, I notice that if we go to main menu from Apple's UI, then timescale is frozen here.
So we're going to fix it now.
Okay.
Other than that, works good.
Okay, let's fix the bug and then we can go to the next video.
That fix would be very easy.
We just need to go to main menu and set time scale to one.
Let's go.
UI.
Main menu.
Over here we can do time dot time scale equals to one.
Very nice.
So we did make a build was not that difficult.
And you can adapt it for different devices just by changing device over here in the simulator window.
Yeah, you can try different things and see how it works.
And yeah, I think there is not much left to do.
So let's go to the next video.
I'll see you there.