Hello, guys.
In this video we're going to make day and night system can be pretty easy again.
We're going to use acid store.
Let's go to window.
Acid store.
We're going to type here.
Just I'm sorry.
Are we going to type skybox?
This is the one.
Where is it?
This is the one make.
If you want to make it easier to find, let's just click free asset over here.
Yeah.
So this is the one.
I will attach the link as well.
We're going to click Open in Unity.
Then we're going to.
Oh, disappeared from my list.
Why is that skybox?
Yeah, we're going to do a download and then import.
Let's click import.
And this asset is a bit heavy.
There are some extra meshes and materials that we don't need, so I want to show you how to delete them.
What can you delete?
What you cannot?
Let's click reload.
Okay.
So we're going to go to this folder box public.
We don't touch utils, but we can go to user and delete this user folder.
Over here.
Well, let me make it a bit bigger.
In the icons, we don't need a PDF file.
In the demo matches, we don't need these matches because this is just the models from them.
I seen that was with the asset.
So we can delete this one.
We can delete them since we don't need them, we don't need to touch textures.
Be careful there.
We don't need settings.
We can delete settings.
We can go to prefab and.
Delete this prefabs of the meshes fans Fire tree.
We don't need it.
In the materials.
We need to delete everything except skyboxes.
So these we don't need delete.
Okay, now let's set it up.
Let's go to main camera and change this.
Clear flags from solid color to skybox.
Now we're going to go to window rendering lighting environment.
And here we're going to change skybox.
Let's find our that we need.
There are three of them.
Let's choose day.
And this is already pretty.
I really like it.
What we can do to make it better is actually to hide the mountains.
They don't look really good with this one.
They kind of hide in the sky behind.
So let's find the mountains.
I guess this is the fifth background.
Please don't switch off the object.
Just select the sprites.
And make them transparent.
All right.
Because we have Polygon Collider on the ground five and we cannot switch it off.
We need it.
Good.
So basically, this already looks good.
And just what we need, I think looks amazing.
I might not sound so excited, but this is because I did it before and I was really happy at that time
when I found it.
But now it's just like, okay, beautiful sky.
Yeah.
So this is how it's going to look.
And you have to agree with me.
This makes this game so much more beautiful.
It's just breathtaking, I would say.
Yeah, this is breathtaking.
So now let's make a day night cycle.
And actually, we're not going to make the night cycle because how long is the one run?
Come on.
20 seconds to one minute.
But we can switch random skybox when we play in the game for the first time or on each run.
How we do that?
Pretty simple.
We need to go to game manager because this is kind of a way for us to control everything.
Now I want to change this header.
Honestly, I want to do per chase.
Purchased color because when I saw it in the inspector, I didn't really understood what is that color
in for?
Now let's make another header.
Just here, Heather.
Skybox materials.
And then we're going to need we can do private serialized field, private material.
We're going to need array.
Sky box.
Matt Okay, Now let's go and create a function to control skybox material, because we want to call
this function from the UI in the settings.
If you remember, we have buttons to control that.
So how I want to do this, I want to place material of the skybox.
They under number zero and night under number one, and the third one, the blended.
I will not place it.
It will be only in the random list.
Now let's create a function public void.
Set up skybox.
We're going to pass our value through this one int i.
So we're going to need a number.
Then we're going to do this.
Renderer settings dot Skybox equals to Skybox Matte A and this way we can switch between them.
Now give me a second to explain.
Why do we use an AI in there?
We need this index to check if I is less or equals to one.
And if it is, we're going to either choose the skybox or a knight skybox.
So let's do this.
If I is lesser equals to one, then we're going to choose skybox.
Matt I in any other case, we're going to choose random.
I'm going to duplicate this line and just type here random range from zero to skybox material dot lens.
And right after we chose the skybox, I want to save this number for our next run.
So it's going to be just player press set INT And we're going to need the number skybox settings.
And we're going to pass an I number.
Now, let's call this function in a week.
Set up skybox and it still need an integer, but this time we can get it from player press.
So let's copy this, paste it in and change set to get.
We're not going to do it here because at the moment, if nothing is saved, it's going to choose zero
and zero is our day skybox.
So basically daytime going to be set by default if nothing was saved before.
Now, if it doesn't make sense to you too much, wait for a second.
We need to create a UI button.
Let's go to UI mean.
Yeah.
Somewhere here, we're going to create public void switch books.
We're going to pass an I int index.
Inside, we're going to call game manager.
Game manager, that instance that set up skybox.
We're going to pass index as well.
And I guess we can play a sound when we click in this button.
So let's copy this line of code and paste it in here.
All right.
Good enough.
Let's go to unit two now.
First, I want to open this array.
Click.
Lock it, then go to folder with the skybox over here.
Skybox.
Demo material.
Take the skybox material.
First day, then night, and then blend like that.
Now we can unlock it.
Go to canvas.
Sightings Saturday night and random.
Go below click plus drag the canvas.
Find UI main.
Switch skybox.
Now we need to give it a number so they can have zero night.
Number one.
Random can be anything bigger than one.
I'll choose number two.
Now we can go to settings and check this.
They.
Night.
Day.
Night.
Day.
Night.
Random.
And whatever you choose is going to be saved for your next run.
So, for example, night.
Good job, guys.
We are really close to finish.
Really, really close to finish.
So just hang in there.
There are a couple of more videos left and you will have yourself a pretty finished game.
Let's go and do this.