 Hello guys welcome back to another video It's been a really long time since it uploads this YouTube channel And I thought I would start the idle game series again, so I felt like I did a that's a good job last time and There's not enough tutorials up there and I feel like that I've Improved over the ever since I've uploaded and I thought I'll start fresh So we're gonna go to Unity I Already made a new project, but I'll show you what it looks like if you're new to the Unity so you You'd open it up. It'll look like this here at my games. You click new Name whatever you want and for the template choose TD 2d and then just choose whatever location you want So I got a project already. So we're gonna set this up So what's nice about the latest one is that it starts you off the scene You know to save it and then make a new folder To clean it up. We're gonna create a few folders. We're gonna do scripts and I don't think we'll be using images. So we'll just keep seeing some scripts for now and a 2d game requires a Canvas so we're gonna right-click or go to create And we're gonna go to UI and then we're gonna go all the way down to canvas So now we have a canvas that's been created This adjusts the size of your free aspect window in the game So I'm a mobile I'm mobile dev now. So I like to make custom resolutions So right here you click the plus make whatever you want. So for 6s, it's oops. That's vertical You just do 640 by 1136 that is the iPhone 6s default resolution. So that's 6s Portrait and There we go. You have a resolution ready to go But if you want to do windows just do Make a new label 1080p 1920 by 1080 do whatever you want. So now you have a 1080p window, but I'm gonna go with the success So first we don't see anything because there's nothing on the canvas We're gonna create a text which we right click on canvas UI text I'm not really sure how to use text mesh pro, but I would recommend text for your beginner text mesh pro has more options and you can do a lot with it Change it to whatever size you want it to be I'm just gonna put a dead on the center See we'll have our text like right here now that line that we want it in the center For each vertical and horizontal and let's make the text bigger. Let's make it a 50 font So you can see it changes color to whatever you want. I'm gonna change your mind to white and let's see Let's do a currency as coins. So we got zero All right. So now we can see stuff, but we can't really do anything yet So we're gonna right click on canvas. I'm gonna get UI and then button. Let's create a button for us Scroll the zoom in you can put this wherever you want. I'm just put mine right in center and If you have any sprites you want to use or images just you can change it here if you wanted to But I'm just going over fun about polls for this video and Creating the basic concept. So I'm gonna try to keep these tutorials really short simple All right, so we're gonna do click plus one Just one coin We just changed the button text by Opening up the button by clicking here and then the text right here So what we can do now in order to actually do something we can make a new script So I'm gonna do it on the text just to make it easier or what you could do is that you can right click on canvas and create empty Just do my game manager here This isn't making a million scripts you can all do you can just do it all in one We're gonna just can call this idle tutorial Game and a script and it's a C sharp. All right double-click to open it. I Have a visual studio installed so it'll automatically open that for me once it does All right, so we have our new script. We start with our our packages System collection system collection generic you really won't need these so we just need you to the engine and in order to access our text right here we have to Copy paste that and do dot UI because that basically gives us all the methods and objects and classes which is something like Oops public text for example, which we'll need so we're gonna do it make it create tech. We're gonna create text or click Name whatever you want. I'll call mine coins text where that will be this text right here So I'll just call this coins text to make it easier for you guys to see So I'm gonna delete these two methods because we only need a few at the moment and in order to Actually have numbers we have to create We have to create a variable. I'm gonna do double because they have a limit of one to the 308th power Which is a big so if you really want to make a big game that's highly recommended, but you can import other stuff Such as like something called break infinity or you can go really really really big like 27 but that's not for today So what I see is that a lot of tutorials actually do floats No, don't do floats because that's one to the third like once the 38th And that was my big mistake when I became and I know that besides I started using floats instead of doubles or beyond So we're just gonna use a double. It's just good practice. Anyways floats are not as good. They're really good for Like progress bars and stuff like that or timers So we'll just save those coins. Alright, so now we have a text and we have a number named coins, but it doesn't do anything yet So we want to create a method called public void of start So what this does is that unity automatically runs the start method right as you load the project Well, there's a few that start before that but it's the main one that you want to use to initialize stuff So we're gonna start with points equal zero. That's if you want coins to start off with a hundred Okay, you can start with a hundred. This is the good place to start and That's all we need to do there for now Next we need something to update every frame That's public void updates. This updates every frame Since I'm on a 144 Hertz monitor it will run this 144 times a second. So Let's see. We want our coins to display something. So we're gonna copy paste our coins text Or we're gonna put the dot text attribute to it Just so we know that we're saying, okay, we want to edit the text right here This is labeled text. If we wanted to change the font, we would do dot font, but we don't need to do that So we got a lot of stuff you can do in the code. So we want the text to say this right here. So we're gonna do coins Colon Space we need a space because if we don't then there would be no space between it So every character matters and we'll add a plus and then we'll do our coins, which is the number So now when we run it'll it'll say this exact same thing right here right now Unless this coin value changed to one. So let's say we want this 123 and we save it So game manager so before we can do anything in order to actually display text We have to drag the coins text into the script Right here into the editor Or the inspector and now it should work. So we should see coins 123. There you go. One coins 123 That's this right here. So if we change this to zero, let's say coins zero So we need the click button to actually do something to make this number go up Because that's the point of this game, right? So we're gonna make our own custom method that we will call using the button We'll call it You can do clicker clicked or just click just whatever you want you can really call it Joe if you want to just got to remember it, but I highly recommend you not do that. So public void click work So on click when we click this button, we want this number to increase by one. How do we do that? Do coins plus plus one or plus plus semicolon? Why so but this is not a good method This is good if you buy it at a single upgrade that goes up by one permanently like only one time or if you Let's say we set we start the game and you want to count how many times you've started This would be a good use for that But we don't want to do that. So we want to do plus equals one Because we can actually change how much this adds by we can change it to ten if we wanted to but for now We're gonna do plus equals one so we're gonna save that and a lot of you are pride beginners Coding but basically this is the class. This is your packages right here for the first two lines These are your variables your data and these are your methods so we have different ones we have Constructors which are made in several classes which basically Give this is basically constructor right here your start because you're basically start you're basically building the whole class starting with coins equals zero and Then we have the updates which we have the mutator which basically changes what's going on in the code and Then we have the another mutator which click which we're changing the value the value of coins. All right It probably made no sense, but If you've heard those terms before that's just a quick refresher So in order to actually make this button do something you want to click on the button Let's go all the way down to the button script and then on the click function right here We want to put the plus and then we can drag the game manager Which is where our script is located into the object right here and then for the no function We click that we clicked our script name idle tutorial game and then we click the click function There you go idle tutorial dot click that is this right here because it's part of the idle tutorial game class So now once we click it should work. We should see this the number go up. I want There you go. It goes up. I want because every time you click this button It calls the on click function which calls the click our public void click method And it refers to our class So this is a really short and simple video, but basically this is the Basics of how to like start your project what what certain methods do and stuff like that If you think you can go on from here good luck to you if you want to continue to serious I will be posting more videos as soon as possible Thanks for watching if you have any questions comment below. This is a very short tutorial just to Just to warm you guys up. I guess Anyways, have a good rest of your day. Peace