Unity Tutorial: Idle, Clicker, Incremental Game | Octo Man | Skillshare

Unity Tutorial: Idle, Clicker, Incremental Game

Octo Man, Let's make your dream game a reality!!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
41 Lessons (4h 3m)
    • 1. #0 Introduction

      3:39
    • 2. #1 The Concept

      10:17
    • 3. #2 Unity Layout

      2:00
    • 4. #3 Scriptable Objects

      6:12
    • 5. #4 Calculating Cost

      6:58
    • 6. #5 Calculating Income

      2:00
    • 7. #6 The First Drink

      3:24
    • 8. #7 Editor Scripting Previews

      8:59
    • 9. #8 Creating all drinks

      8:37
    • 10. #9 UI 1 Itemholder

      9:53
    • 11. #10 UI 2 Scrollability

      7:02
    • 12. #11 UI 3 Scrollbar

      2:36
    • 13. #12 UI 4 Changing the Look

      4:31
    • 14. #13 Itemholder Script

      3:29
    • 15. #14 Buy Button Script

      3:36
    • 16. #15 GameManager 1

      8:47
    • 17. #16 GameManager 2

      4:53
    • 18. #17 GameManager 3

      8:35
    • 19. #18 GameManager 4

      15:44
    • 20. #19 GameManager 5

      4:02
    • 21. #20 GM6 BuyItem

      13:57
    • 22. #21 Watertank 1

      7:09
    • 23. #22 Watertank 2

      9:03
    • 24. #23 Click Popup Text 1

      5:30
    • 25. #24 Click Popup Text 2

      3:58
    • 26. #25 Click Popup Text 3

      4:33
    • 27. #27 Money UI

      4:14
    • 28. #28 GPS UI

      8:22
    • 29. #29 Save Function

      8:06
    • 30. #30 Load Function

      2:22
    • 31. #31 Saving

      3:54
    • 32. #32 AutoSave

      3:35
    • 33. #33 Loading The Data 1

      8:47
    • 34. #34 Loading The Data 2

      5:19
    • 35. #35 Loading The Data 3

      6:49
    • 36. #36 Formating Numbers

      4:49
    • 37. #37 Rearrange Editor Scripts

      1:07
    • 38. #38 Game Saved Indicator 1

      4:35
    • 39. #39 Game Saved Indicator 2

      6:36
    • 40. #40 Clean Up

      3:12
    • 41. #41 Conclusion

      2:16

About This Class

0aa8ed24

In this Unity Course you'll learn how to create Clicker, Idle, Incremental Games with Unity Game Engine. I will cover all basics you need to start such a game.

This course is made for beginner, which want to learn the basics of Clicker, Idle, Incremental Games.

We are creating a system to:

C# (Monodevelop)

  • create Scriptable Objects for our items to simplify processes

  • create a basic Editor Script to show Previews in the Editor

  • create connector Scripts to easy access User Interfaces

  • create auto - saving and loading the game

  • create a exponential function for the cost calculation

  • learn to round floats to 2 digets after komma

Unity (2018.2)

  • setting up our Editor, so we always see the important content

  • creating our own User Interface for the game using the Canvas System

  • implement scrollable content for our items / itemholder

  • implement a scrollbar

  • create an Object to click on

C# Fundamentals

I'll cover how to use and/or create:

  1. Variables (float , int, bool, string ...)

  2. classes

  3. functions

  4. if / else statements

  5. for and foreach loops

  6. Lists

  7. Arrays

  8. Coroutines

Course Material

i provide the following Material with the Course:

  1. 8 different Drink Graphics as *.png

  2. 1 simple Background

  3. 1 Itemholder Background

  4. 1 Watertank Graphic to click on

  5. You have to write the code on your own, i do not provide the final scripts!

All other graphics for Menu's, Icons, Images or Buttons need to be created on your own.
All Materials i provide are for education only and should not be in your final release!

Conclusion

In the end of this course you will have a fully functional Idle, Clicker, Incremental Game.

So what are you waiting for?

Let's make your dream game a reality!!

Level: Beginner
Video Course Length: ~4 hoursĀ 
Unity Version required: 5.3+

Transcripts

1. #0 Introduction: This is the introduction video off how to create an idol clicker Incremental game. What you learn of this course is how to create thes item holders or place will those for our calculated gold per second amount and the coast of thes items. You're gonna learn how to suitcase the total money we have as well as the gold per second coming in. We're going to create this little water tank or water dispenser Teoh to make it so that we can click this and earn or first money. And of course, we can buy our first water, so we gonna unlock things like informations. As you can see, we currently don't know what the next item is going to be as well as what the image is going to be. But what we know is that the next item is going to Costa. 100 bucks or money, or we can now do is we can keep on clicking, of course, and by even more items toe in total, just to make sure to unlock the next ones. Also, as you can see, we're gonna implement an order safe action which is saving all the informations we really need for this particular game into the play up refs. Once you get enough money, you can unlock the next one, which is going to be, as you can see, a lemon jewels with the GPS off one and the current amount off one s Well, so this one is going to Costa 150 in the next one. So we talk about exponential functions to increase the coast per item exponentially. So whenever we approach chasing the next item, the next one is going to be even more worse than the last we bought before all of this calculations and all that sort of stuff is going to be content off this course. Also, you can see that the next one would even cost 1000 bucks or money to unlock this one or so . As you can see, we're gonna have this A total GPS off 1.2, which is calculated together by the current lemon juice and the GPS off the water in here supposed together is going to give you the total GPS over there. So we do all of these calculations, we're gonna create all the cask rollerball content. I can cheat myself some war, some money, if you like to. Just to see what's going on over here. We're gonna talk about game and it just in all the other set of functionalities over there . We're gonna talk about the big numbers if you like to. As you can see, we're gonna have a 1,000,000 right now so I can even unlock more items over here. Also, we're gonna create the scroll of a content and this list filled automatically by whenever we're buying something. Also, as you can see, everything is updated correctly. We also create or our own the ESC writable objects, which we'll ask the calculating or the quantity into. We're gonna put in some editor coding or scripting to visualize what is the unknown image as well as once the current drink image. Are we going to do all of that for all the different types off your content? We're gonna have into a want to have entered. So if you want to learn how all of this stuff it's working the best way you can do just come into wizard my course and take it. So I hope to see you in this idol course. I hope you will enjoy this one. And I gonna see you in the course 2. #1 The Concept: Hello, ladies and gentlemen, my name is up demand and I'm your instructor for the next couple of hours in the idle clicker intra mental game course. Let's talk about what is a clicker game and increment the game. How can we of wolf things and what is going to be about everything? Are we gonna take a look into? So at first of what is an Idol Calica instrumental game? It is something like you probably have seen before on cookie clicker and several other possibilities and possible games. Um, where you have to click something toe, earn something. It is not always Dad, As you probably know already. It is also more like evolving, getting stuff automatically back like currency or in cookie clicker. You get cookies to buy, you know, more businesses or some grandma's with which are automatically cooking your cookies or baking your cookies and all that stuff. Let's talk about teams now. What we want to go to is we kind of build some kind of business tycoon ish shop system over here, as you probably have seen in the in in the introduction video already so, but what else can we do with dad whenever we have started. So let's talk about RPGs. As you probably know, there are some RPGs which are based on this the same principle. So what you gonna do to click a monster? You reduce the hell's once the health is gun, you're gonna get money to purchase into your clicks or you purchase into some warriors, Let's say, or fighters which are going to do automatically damage for you. Then you evolved in stages like if you have killed or distress droid 10 something 10 monsters, you're going to go to another stage, for example. There are hundreds of possibilities to mix and match all of that. So that's what we can basically do the same way with the same principle. So we're gonna go to the basic business style one. But RPG is basically doing the same. But since I wanted this to keep as simple as possible and also beginner friendly, without much animation and stuff, we gonna go with the business tycoon of a here or shop system where we're going to sell different let's say drinks and stuff, and also whenever we're putting or you're clicking on water, Cuba is something that we're going to get some coins or actually awesome gold. Whatever, Teoh, actually start the business. What? You can also do it. You can put everything into space. For example, whenever you can build something like a space station or you can buy and self or cell in this case, a cell ships or you're gonna let those ships fight for you against whatever Elian, monsters, whatever, all of that can be done in the same way you couldn't even make a jumping dot And he can purchase more jumping dots to do even more in whatever currency is. So you have hundreds of possibilities in case off themes. Same for farms. You can get a born. You can probably buy a pig and or a cow or whatever our sheep and whatever they produce, gonna give you gold in return or produces something for you which you can sell whatever all of that can be taken as were we gonna create a bass, the bass off every kind of click a game. And you can optimize that to your needs later on. In case of siege up content, we take a look into lists, inscrutable objects to make our life easier. We're gonna look into four and four each loops, so we see how we can make use of them. And also, we gonna need some if statements, of course. So just to check if something is true or false, probably we're gonna take something like and negative numbers in between. So we probably look into expressions, but I'm not promising that. Then we're gonna take a little a small a rather small look into added a script, getting where we just ah, he has showcased something onto our scriptural objects so we can see sprites where whatever representing our current drink, we want to sell. Also, we're gonna look into core proteins because we don't want to use update all the time. This is going to be to resource heavy. So we're going to start one core routine, which is doing basically everything for us without any problems. And we're gonna take a look into a clickable object that is going to be the one I'm gonna talk about in a justice second again, We're just once again this water think whatever way you can get one coin on one money won gold. Whatever Pill click. Also, we're gonna take a look at the mathematics, meaning we're gonna take a look into exponential functions. Which means whenever we're purchasing something, we want to get something in return, Of course, which is going to go up like linear. But we want Teoh. Have the purchase price go up, exponential. That means we're gonna take a look into a formula which is calculating all the coast automated for for us. Dependent on how much off Whatever we have already and make this one exponential, we're gonna take a look into this Also, we gotta look off course into adding and subtracting like money. And also we want to take a look into rounding floats. This is well, basically not a rounding directly. But the last two digits is the ones we gonna we want to take. We don't want to have, like, a 30 calmer and then, like eight numbers after the comma that's actually unusual and not necessary probably will also take a look into big numbers. And now we can avoid problems because afloat or an inter jail, whatever number it is, can Onley hold a specific amount of numbers in it and is not it like you cannot have, like, 10 billion or cotillion em whatever coins into a specific float, for example, So we probably gonna take a look into this. Also, we want to look into interface design. Meaning are we gonna I gonna give you some material to design stuff around. You can make. It would however you want and like, But it's important that you for especially if you're a beginner, you follow up whatever. I do it. So to understand what's going to happen also, we take a look into scroll herbal content, meaning all of these poor like these are our containers or image or item holders were whatever we going to purchase, you were gonna place the buy button somewhere. Here is going to be the preview image of whatever we are putting in. You're gonna put a title text and whatever the current GPS amount in the coast off this item is, and we whenever we have, like one or 10 or whatever off the 1st 1 we gonna unlock the next one. Probably we're gonna do this like directly so the player does not get distracted and the list is going on. Also, we probably put in a scroll bar over here. So the users see. OK, this list became longer and is somewhere outside of the playfield, and I cannot see it, but I can't rolls through by dragging with the mouse. But the swirl bar is probably helping as an indicator. Oh, by the way, there's something down below, so you probably want to check it out by using this crowbar or your mouth or your finger to touch. All of that will work at the same time. Also, we're gonna take a look into, ah, grid layouts. Meaning in this case, it's going to be a vertical grid layer group. Probably we're gonna take a look into horizontal ones as well. Or a direct grid layer group doesn't really matter. Basically, everything works the same. It's just how you organize stuff. Also, we're gonna take a look it to content size, meaning whenever we have a container where quantities is inside, we want to fit all the content into the size off the layout. So whenever we make it scroll herbal, the scroll bar automatically know Okay, I have to scroll even more because the content is way bigger than it looks in the top over here. We're gonna create some let's say, bar where or money has shown and probably our GPS, which is going to represent gold per second and probably our CPS, Or actually it's going to be a GPC like gold per click. And maybe we're going to implement something to also are great. The click ability probably do it through achievements or whatever. I'm not 1% sure about that, but we gonna get to the point while we are getting everything started and running. Also, if we are done with all of that, you should know how to implement click ability or actually implement the click ability. We're gonna start with one gold per click in here. We're gonna place our water tank, someone here once again. If you are more like after an RPG style game, you're gonna place your monster over here maybe Bill, give it some helds or h people are and fill it up. Maybe in the next recession later on, or if there are more than enough requests, then I probably go into and take a look into RPG style game. So where you have a house bar over your monster, you can click the monster and the monster goes down and gives you some coins and return whenever dies. Basically, this is nothing much more. We can all implement all off the functionality later on into the scriptural objects which are basically our base data container. And we can design our enemies just inside the script of all objects. We can pick from a list off enemies and stuff like that and put them just into this. Once again, there are hundreds of possibilities. And once again, with that base off knowledge, I gonna show you in this course, You were absolutely able to put it into any kind in any steam you like to. So let's get started. I want Ah, I hope to see you in the next session or into the length lecture. Of course, where we're going to start with basically designing our first script herbal object. I guess 3. #2 Unity Layout: welcome back to the course in this lecture, we want to start to create a more first inscrutable object. Before we do that, I want you to make sure, especially if you're a beginner, that the consul on your screen is always Wiz Herbal because most of the people have the problem that the consul's not visible and they don't see any problems. Any errors coming over here because it is only Britain, like under the very low bottom, which you currently can't see, But you want to make sure that the console is always winnable. It depends on what how your design is for me. I always like to work with the scene view in the upper corner or in the upper most area over here in the top bottom left. I wonder if my game into Ah, just a smaller window doesn't really matter about the size, at least not for the moment. And the consul needs to be for me, always like in the center, in the bottom, here next to the game you. So whenever I'm not and maximize on play and so on and so forth and whenever I'm in the editor, I have like everything on screen, so make sure you are confortable with whatever the setting is. But make sure the most important one is the consul. The project window needs to be seen as well as the hurricane panel. At the moment, we don't care about the hierarchy panel. Also, you want toe always have the inspector somewhere on your screen. So if you are happy with your layout, you can always go over here to lay out and say save layout. Then you can give it a name. I have mine over years against you ever octomom in their layout saved already. So whatever, whenever somebody else's working was yours changing a layout, you can always so like this and you're gonna be automatically back to wherever it has been before. Just keep that in mind. 4. #3 Scriptable Objects: Welcome back to the course in this lecture, we want to start to create our first script Herbal object. What you want to do to want to keep everything as clean as possible. So what we create at first it's a folder called Script. In those scripts folder there will be everything inside and only about that. Scripts. Make sure you always work as clean as you can. Next one. What we want to do is we want to create a new C shop script and call this one drink. You can name it, whatever you like, whatever the item type is going to be. But this is basically our main object for descriptive objects. Opened this one up in morning develop or vicious studio, whatever your police and like personally, I like to work with him on a develop and I zoom in and for you, what we want to do is of course, we want to make sure that this is not type model behavior, but script herbal objects. So we're gonna change this its first. So double click it and say script herbal object. We don't need start and we don't need update. What will we need to make use office in the second some user interface in the name space. So what is descriptive ble object? A script? Herbal objects is like an asset class where we can put in data and store it into. For example, the resource is father or wherever we like employees. And we can always excess it wherever we have a type off drink. In this case, off prescriptive object collapse successive. We're gonna talk about that and a bit, but I'm gonna show you the odds and good things. So it's critical objects, basically nothing else in the class. But we can actually design it for needs put in functions as we like and we can inherit later on from inscrutable object to create a script Herbal object Later on, we're gonna have to put in square brackets over here, and we need to say we want to create an acid menu. For that. We open close parentheses and inside over here we can say we want to give it a file name we're gonna say is equal and in quotes we give it a name in this game. It's the new file name. For example, New drink. This is what you're gonna see whenever this file is getting created new. After that, you can put a comma and we can also give it a menu name. We could also say equal. And then we say in quotes, whatever the menu names should be, for example, we can say its idle game. And then we can make a slash and can put in, for example, drinks. So all drinks will be in this man your name. Let's save the script. The quick shortcut is going to be controlled S or command, As I guess. On the MEC, I'm sitting on a PC, so I'm not 1% sure. So now drink is created with a create man acid menu possibility. Whenever we are right, click create, we're gonna now have our own idol game acid over here and we're gonna have drinks. Whenever we select this, we can create a new drink into all my assets. For the whenever were on wherever in which folder, wherever we are, and we can give it a name blah, blah, blah, we can keep it as new drink doesn't really matter what it is named, but later on, we gonna take a look into this. Okay, so now you know how to create an asset? A script? Herbal object. Now that's pretty quick. Fill in some data we need for our drinks. So make sure you have all the curly braces over and clothing a descriptive will object, and now we can go continue. At first we want to put in all data as public. Very Abel's, as long as we need access to them so we can see them in the inspector and change them according to a one needs. So the very 1st 1 is our drink name. So what is on my name? And that's what we can also read later on. From next one, as we want to have a public, let's say float. And this is going to be ah want base price. So the base price off this particular drink ended will never change. It will always stay the same. We're gonna talk about set up in a bit, actually later on, then we need a another float, which is going to be our multiplier. This multiplier is important later on, for our exponential expression or exponential calculation. We talk about this as well in a bitch So this is going to be some number between 0.7 and 0.15 We're gonna talk about this numbers in a bit as well. Next one is we want to have a public float in. This case is going to be in base income. So how much do we get as a basic income from this particular drink? Whatever this. Okay, so the next one is we need some sprites so we can say public, right, And we can say drink image. So this is going to be our image, which we're gonna see whenever we have purchased at least one. We're going to see this in our interface. And also, we want to have another image over here, which we gonna name unknown drink in its This is something where those question marks are appearing whenever we know have not purchased one specific m your drink. But we could, especially when we are able to buy it. Then we're gonna put some question marks into this image. We're going to talk about this in a bid s well, and that's basically everything we need for inscrutable objects. 5. #4 Calculating Cost: Welcome back to the course in this part. I want to talk about the script of the object a bit more discreditable. Object now contains all necessary data, and we are able to put in some data into it. We can also do is we can create frightens to calculate the coast in case off exponential formula. I gonna type the formula out year. So you probably want to do this as well. But actually that's absolutely up to you. So I want formula is going to be. That's how everything will be calculated. The price off, the item off the drink is going to be equal to the base price. So whatever the base prices, then we multiply that by our multiplier, which is going to be somewhere between 1.7 on 1.15 and then we're gonna say we, um we put a square or an exponent into this by a specific number n this specific number end is going to be the amount we already have. This is the function how we want to exponentially calculate the price on whenever we want to buy the next item. How can we create such a function. Actually, we want to create a public. So we have access from any point in the game. Make it a flute. Since we want to return afloat number, which we're gonna round down or up depending on the numbers we want to see, let's name it, calculate Coast. So there are different possibilities to do this. And once again, you want to create a function of type float to make sure to return afloat in the ends. So at the very, very last, we want to say we want to return something about afloat. Otherwise we're gonna get problems. So just keep that in mind. Okay? In this function, calculate coast, we want to put in an amount which is going to be the amount off the item we currently have . Let's say we have one drink already. We gonna calculate that, And based on this, we calculate the price for the next purchase. How do we do this? First off, we create a new float over here that's going to be a local float. And I gonna name it may be new price. So and now we're gonna go through the price formula, which we have over here and do basically the same. We say we take our base price, multiply that by, uh, expert meant, and the exponent is going to be the multiplier times the exponential amount. In that case, we're gonna use a function called mass F dot pau. This say's as you can also see it returns F. It's going to be the first number raised to Power P. In this case, it multiplies itself by the amount or the amount of times it is going to be implemented into amount, like in Pete. What does it mean? Let's assume we have a multiplier off 1.7 and an amount off one. It's going to take this one and forms the square. Oh, it's good squaring this one multiplied by one. But if that is too, then it's going to be We can put in a calculator pretty quick. We're gonna say, OK, the next one is going to be one comma 07 times itself. So this is going to be the next multiplayer by the base price. And if the base price is going to be, let's say, 10 we're gonna have the next prize is going to be 10.7 instead of 10. If you do this times 345 10 11 whenever or 100 you're gonna get different prices. We can also check it out later on if you like to. But since we don't know the amount we're gonna put in over here, the amount which is going to be this argument. We're gonna send this incoming argument into the power and this one here is going to be our set multiplier. So I put in multiplier Currently, I'm thinking about taking this one off so we don't have access from outside and this is going to be always a fixed number. But on the other hand, we might want to change something later on or you might want to do this so it depends if you want to keep this public and you don't and you want to change this later on on every item you can. But also we can send a base on the for example toe 1.7 Or we can also say we want to have a base on this. Don't forget to end the line. Was this F because an f of always beautiful or or float always needs an effort. The end. Okay, so now we have the base price. Now we need to round it. First of of course, close. The line was a semicolon. Now I want to round it to two digits after the comma. So I call it around it over here. And the rounded is going to be equal to We typecast the incoming number into float because usually mass half don't round returns and inter just so it rounds as you can see returns f rounded to the nearest indigent. That's what we want to avoid them. And also we need to have flowed in the end, actually, So we need to typecast this one into afloat. So we say float mess f dot round What do we want to round is actually the new price we have calculated. We divide that by 100 and at no Ah sorry. We multiply that by 100 then we divide the result by 100 as well. This way, we gonna round it so that it always returns and number was two digit after the comma. Now what we need to do is we need to return the round number so we say return round it and that's it for the calculating coast 6. #5 Calculating Income: welcome back to the course. In this point, we want to implement how to calculate the income per item. So in this case, we're gonna go a linear. Ah, yeah, lets a direction to see how we can increase income per per checks. So what we create as a new public float and in this case is going to be called calculate income. And of course, we need to know how much we do have already so we can calculate this correctly, since once again, this is off type float, we need to return afloat. So we say return. And now we can return any number. And what we know is that the base income has been set by something, so we call it, take base income, and now we multiply that just simply by the incoming amount. So now we know per item. Whenever we call, calculate income and pass in the correct amount, we just multiply the base income by the amount. In that case, we're gonna have a linear workflow over here cause one time, so that's a tennis 10 2 times 10 is 23 times 10 asser tion zone and so force. So we increase the income linear. This one over here is exponential and rises up quite ok is depending on how high the multiply its The higher the multiplier, the faster the price rises. The small other amount is that smaller the changes or the rise and prices going to be Just keep that in mind, okay? And that's everything we need to dio for calculating the income. 7. #6 The First Drink: welcome back to the course. In this course part. We want to create all necessary script herbal objects so we can light on, refer to everything and set them up as good as we can. First off, please open the first package or whatever the tax your packages, which I have sent hopefully into this lecture and what you want to have as you want to export all the drinks. In total, there's a drinks amount off eight, and there's also an unknown. PNG was two question marks on it. What you want to do is you want to go to your assets. Will that create and you folder and call this one textures. This Texas Wilder will always and always only contain textures like two D objects or images , whatever even background some button images. Now what do you want to do is you want to drag all the unpacked items like all the drinks and the unknown image into the Texas holder? Select them all the holding down shift and just like go from one and then to the other side , hold on shift. They want to change the type the text type from default to Sprite to do I and apply the changes. What you're going to see is that these images are totally transparent in the background as well as also for the question mark items and they are all squared. If you want to optimize later on four, let's say mobile games. You want to maybe reduce the maximum size to be 5 12 because originally, these are not for higher than that, as you can also see over here when you select one. Now we can use old off these drinks and put them into whatever the order you like into our inscrutable objects that's created descriptive will object. I'm gonna name it one. Then I leave a space at the one is important later on to see what's going on and have a good order because sometimes things we might be crowded or not in the right order. And I call this water. So as you can see when o however I name it automatically, this one will be at the very top. If you want Teoh have descriptive bill object in another sub folder, absolutely possible make use of it. So what can see now is we can design our water with whatever we want. The multiplier is already set toe 1.1. Want 15 as we already did Or said it too. On the drinks as a base value. All the other ones are empty. I can give it a name like water. I can give it a price. I got not choose 15 and I give it a base income off 0.1. I can also put us right like water and I can give it the unknown Sprite for the unknown drink image. That's it. Water is done. When I want to do is I want to visualize the images off the dreams and the unknown image. So we need to go into editor scripting. 8. #7 Editor Scripting Previews: Welcome back to the course in this part. I want to create some small Aditya script to visualize the drink image and the unknown drink image. The buff or inside descriptive will object. This is not necessary for the game, but probably you find some other use cases laid on for that. First off, we're going to create a new C subscript and I call this maybe asset Prevue. If you have typos, you can always rename them as well as a renamed the class later on, as I do so press f two. I'm gonna rename it pretty quick. I might get a narrow in the consul because the class does not contain the scripts or vice versa, but actually doesn't really matter. And I opened this one up in mono developed or visual studio, whatever you please like and half. I also want to make sure that I renamed the class over here So everything is correct. And I'm gonna say the scripts. I want to get rid, avoid start and update because we don't need them. Since this is going to be an editor screwed. We need to implement an name space called Unity Editor. Also, we want to inherit editor, so we need to get rid off money, behavior and Putin editor. Now what we need to do is we need to say off what type this editor is going to be on where this editor is going to do changes in this case. We need to say costume editor and square brackets it but a buff the class name and open close Prentice's we're gonna need to declare type off, and then we need to put in a type off. Whatever the type is. In our case, the type is drink because we wanted excess the drink class from the editor scripting to have access to the, uh, to the drink itself. We need to create a private drink. We can just name it. Drink. This is going to be the target we're gonna pick in the second also, what we want to see as to tax rece in this case texture two d. I'm gonna take name it text one and texture two d text to you can also put them all into one line board. But for the sake, off visibility. I'm gonna do it this way, and we need to create a special function, which you need to have completely written. Correct. Otherwise you might have problems. This public message is going to be off type over, right? So we want to override something. It's a time void since we don't return anything. But what do we want to override is on Inspector G U. I make sure it is correctly written so Oh, I do you I need to be all big letters in this case. Ever want to do that? First we want to target the drink. Whatever the drinkers were currently targeting. So we say drink is equal to and we need to once again typecast to drink. We need have a need to have a special name which is already done. We don't have to do anything which is called Target. We target the specific object and we need to typecast. This is to drink. Otherwise, we have any object. But we don't know what it is going to be about. No, we have. The target I want to do is we want to create a new gree layout. In this grill, Out is going to be have a begin and in hand and horizontal. I want to have the both images next to each other, like left and right. Otherwise, it will be seen vertical. I gonna put them into a begin horizontal group. And whatever we begin is whatever we have to end. So we say, grill out or G Y layout and horizontal open close. Bryant to seize close. The line was a semi Cano. Everything in between those two will be next to each other, like left and right. Not top to bottom, like up and down. Okay, so what we also want to do is we want to save and check out what's going on. So far, we're gonna check out our water, which currently looks like that, but will be overridden in just a second. Give the compiler a second to run. Now you can see multi object, adding not supported. And we don't have access to whatever has been inside. What we need to do is to visualize that again after the entire result. Will we need to say draw default, inspector? That means it draws whenever has bean in before. Don't forget to save and check it out. And we're going to see our all our excessive points again after the compiler has been done . So whenever we d selected and recent liked our first water over here, you can see everything his bank toe, where it came from. Now we want to put in our images off the textures like from the drink image and to the unknown image above the script. How do we do that? We put this in between begin and end horizontal. At first we want to fill text one. And what we want to do is we want to call the function called Acid Prevue And this acid prevue we want to say we want to get something specific and this is called Get Asset Prevue for me currently, it doesn't really work over here with all the complete. So you probably want to write it 1% correctly like this. Then we put an open close parentheses and we talked to drink. Don't drink image that goes the line was a semicolon. The problem is, the class name doesn't match at the same asset over here, so we need to rename the class to be acid reviewer Also do this over here or directing unity. Andi, don't forget to say that otherwise, as a preview does not really work correctly over here. So now as a prevue should have, get acid prevue as a function name again. Once again, put and drink. Don't drink image as an argument Now we say gui layout dot label And inside this label, we want to show tax one. We can copy and paste that two lines and bring them in here again and do the same for thanks to so in text to we want to tank drink image dot unknown drink image everyone to so text to over here Make sure both is going to be sitting in between. I'm gonna make indented over here In between both groups off begin horizontal and anti horizontal once again withdraw the default. Ah, inspector, Afterwards, if you want to have the steps in front or on the top, you can change just the direction off the threefold inspector and just put the default. Ah, Inspector, Over here in between the begin horizontal and the first begin Ah, and the drink target over here. Don't forget to save and let's go back to unity and see what's going to happen with our ah water inscrutable object. So whenever we click this once again, you can see that the Prevue is going to be created off the water. We want to happen to our game and the unknown image in this case going to be question marks so won't know what's happening. We can basically switch to any graphic we like to and for example, of purple, the blank or red or even the yellow one. And we can just switch through them and let them, actually. So over here, as you can see, sometimes it's a lagging a bit. But give it some time or just repress on these buttons and you're absolutely able to get the Prevue inside. And now we have everything as a base for my first script about object. Now we can also go into and create the other ones, but we need to talk about base price as well as the base income in the next video 9. #8 Creating all drinks: welcome back to the course in this part. I want to create all the other seven inscrutable objects which we need for our other drinks . So in total, once again, we have eight. You can put an even more or change graphics, whatever. But once again, we're gonna go through that registration. Okay, So Waters created was the base price of 15 at the basic income off 0.1 we want to create now is another drink. I got an image to leave a space, and then I can basically name it, whatever it is going to be. It's something like, for example, lemon. So the lemon juice are, or whatever the name is later on can be tended. Or we can design them. We can name them Zeit rules, road Jews, whatever. All of that is up to you. Some mind is called John Lemon Juice. And 11 Jews, of course, need to have something yellowish as well. Asti. Unknown image. So everything is cool. Let's talk about base prices. I want to have all my base prices are going to show you a list. Something like that. As you can see, hopefully is our first water has a base price of 15 and an increment ID or an implemented income off the 150.1. In the very beginning, the next one I want to have is going to cause 100 has an income off one. Next 1000 and 8 12,041 30,000 to 40 and so on. You get the idea. What is all of that about? Basically, you can do your heavy mathematic calculations. Over here, we basically take this income and always multiply this by five or eight. For example, eight times five is 40 40 times eight is to a to 40. And this one times eight is going to be this, then this and this, and he can do the same over here once again. This is no formula I can give you at the moment. This is just some numbers were which you can play around with. If something is taking too long, reduce numbers. If something is too expensive, reduce if it just achieve increase and so on. This is something which you later on have to set on your own. We're gonna use them now as the base again, See what's going on with all these numbers, and that's what we need toe optimize into. I got I cannot keep this over here, but I will take it into every time we gonna create a new script will object if you like to . So the next one? As I said, it's a base price off 100 the basic income off one. And now you are done with your lemon, and we can now create the next one. That's the simplest way to create items, monsters, whatever. Using script, herbal objects. So the next one has probably something about, Ah, I guess it was a strawberry. You can also name a cherry. You can name it once again, whatever you like. And please, I got a name. Mind strawberry Jews. There's going to be the item name or the drink. Name. Ah, The base prize, once again at a scene on the list is on 1000 and two. Income is eight. So we're gonna do this. We're gonna put 1000 year in an eight at the base income and are gonna take the red drink. And, of course, the unknown image of her here. Good next one going to create a new a drink. This is going to be Oops. I forgot to name it. Number four. This numbers, by the way, are now the order where light on, they have to be in. So make sure you keep the order or use numbers in front. So you see this later on? This is something maybe about apple. So he may be named this one Apple juice. Gonna have the base price off. 12,000 over here. And the basic income off 40. I gotta pick the green drink and the unknown emits and we're done. Was this item next one going to create a new drink? Five. If that is going too fast for you, feel free to pause the video at any time and fill in all the data, if necessary. Next one. What is going to be the next one? I have no idea. Let's see, when I checked my textures. Next one is something purple. So I go in here and named this maybe whatever it can be. Maybe a cranberry, Whatever. Cranberry. So this can be maybe my cranberry drink. It has a base price off 130,000. So 1 31 23 zeros afterwards and the base income off 240. We're going to give it the purple juice and the question mark Item over here. Next one is going to be my number six. And this is probably a blueberry drink. Whatever. So we put in blueberry Jews, maybe are gonna name this one Jews as well. So it's maybe a bit better, so you can see we can simply even later on, if you have created more you again just put him in. And most of the stuff is going toe work automatically. So this one has a base coast off, one for 1400 and then another three zeros. So 1.4 million. Let's see what's going to happen when we are checking out of a year. Okay, This number does not change at the moment because it already or still fits into the float. But later on in the next one and the next after that, we gonna have some different changes over there in the basin. Covers wound, 1920 per drink. Next one is going to be something white or black. I have no idea. Uh, depending on whatever the number is or what I named them, basically. So this might be a milk. Let me just create the other one pretty quick. So we just need to fill in the data. Eight is going to be something like a black I don't know Mamba or something or just I just Ah yeah, whatever. It doesn't really matter how you name it, as long as the numbers are incremental, like they are in the same or in the correct order. So this is going to be my milky drink, whatever, and my base price is going to be 20 A 20 million. So 20 then 123123 What's going to happen is it will shorten that already it say's to E plus seven. So two ee means it's going to be 20 plus seven zeros. So or is it? Ah, let's check this out pretty quick in a calculator or wherever, so to zero. And then we have 123123 So, as you can see, it has a 70 so it's a two with seven zeros. That's what this E plus zero seven is going to mean. Just so you know. Okay, so the next one is going to fit in here as well. It will be like something like a 3.3 with nine zeros or something. Or seven zeros. We'll see. So next one is we want to make sure that we give it a color. And, of course, our question mark item and the base income is going to be 15,360. Okay, Cool. And the Black Mamba off girls, we're gonna name it. Black Mamba here as well is going to be the most expensive ones. It's 330,000 and then surround 30 million. I mean, so wanted 3123 This number is going to be a 3.3 e plus zero eight, as you can see. So just keep that in mind. Since this is a 0.3, this is like eight numbers after the last letter at the base income is 122,500. Something like that, you're going to give it our black drink and of course, are question marks. And now we have done Wasel the setups for descriptive object. And we can go and to use it interface design. I guess 10. #9 UI 1 Itemholder: welcome back to the course. So now we are done with all our settles into the Eid import. I want to go into user interface design as well as laid on into the coding mechanics because the coding is basically not too heavy at all but user interface going to need. Or we're going to have a lot of space for different items. We want to put in as we talked about in the very beginning. Scroll ability, content, size fitting and all the other units and items. Ah, and we want to have some holder object which is going to represent everything which we can see into the script. Herbal objects when we wanted create is now the user interface for all the items at first. So what we create at the very, very beginning is going to be a canvas. The canvas is going to be the holder for all graphic possibilities, images, items, whatever. If you are new to unity, it's better for you to go to rectal over here and press on to demote into the scene view. When you scroll out with your mouth and go very far away, you're gonna see this. This is going to represent the canvas. If you are starting new and your product is said to be free aspect, please change it to 16 by 9 16 by 10. Something like that basically laid on. It doesn't really matter what it is, but in case of creation, you want to not have the free aspect ratio because it doesn't make sense. We know. Create something for a 16 by nine device. If you don't have the possibility to change or take this, go here to the plus and enter this one into the list. But I guess it's going to be there. So choose 1 69 60 by 10. You can also go in portrait mode if you like to like nine by 16 10 by 16. But I don't recommend this because we want just some specific items on to one side and another item on to the other side. Once again, if you later on, I actually know what's going on over here. You can change this to your needs as well, so I want you to follow. However, I do whatever I do. Okay, so what we need is an event system. If you don't have to send your senior canvas will never work. Make sure event system is always in your scene whenever you have a canvas. Otherwise, once again no indirect. It's possible next one super important. Go to canvass scaler into your inspector and chase. Change it from constant picture size to scale with screen size. Do this now. Otherwise, later on, you're gonna have some serious problems with user interface design. When you have that, we can go and create on first you I image this image is going to be our placeholder, which is basically deter mining the design off our left side and right side and all the other sides. What I want you to do is pro. You want to do this somewhere in the left May way we can go and use some of these anchors. So I hold down the old key and put over here so it will automating the centers and put this into a stretch mode. You want to have this on the side? You can also do that. But stretch on the site is probably the option one to go to once again. Hold on old key. Now you can actually manipulate this by dragging it around a deter mined the size. How big do you want to have this place? Holder were light on. All the items are going to be in inside over here. This is also going to be our ski Raul. Ability, I would say, is going to be planted into this. What's going to happen when we change now? The to 16 by nine? It's absolutely no problem. It will just squeeze it a bit as well as put it into the correct order. Well, hopefully this image is going to be our scroll wrecked, so please rename it to scroll wrecked so you don't lose focus next one. We don't want to put in anything over here into the score erect, at least not full the moment. But make sure you don't make it too huge. So we have some space for a squaw or bar on the left. On the right is up to you once again, but we want to have an extra space, so it's not in the way. Also over here on the right side. As I already said before, we want to have something to click on and also in the trouble we want to have all money bar and all that stuff. So keep enough space into that. It doesn't really matter by the way of your industry demote or to demote or to d. C knows Really seen Canvas is always represented in both off piece. If you don't like the three d mode, if you have created one like Ideo no ivories Just change it into the settings if you like to or just keep it as is and just changed the camera to be a solid color. We don't cover this at the moment. Next one is going to be our space or placeholder. Let me tend to the scroll. Rectory can see stuff better are gonna make it. Maybe is something like this. So I just sending a bit selecting it, right click and we're gonna create another image. I want this to be stretched left to right over here. Hold on old once again and stretch it to this Is that a stretch is going to have one specific number which we cannot see in the West off that because it's once again it's stretched. But it is important that we stretch this to the outer border off the scroll wrecked, so it's always keeping the same size and distance. Currently, mine has a height of 100 which is absolutely good. We're gonna make use of that height as it is, and we put in now all the information into this. First off, I want to you to rename this one to be item holder. You can name this whatever you like, but I want you to understand what we're going to create over here in tow. Item hold. Are we gonna create probably another image which is representing our Ah, yeah, our drink image. And I want to give it the size of 90 by 90. So it's not that huge. We can also take this a bit gray or something. So we see where it is going to be, too or related, and I'm gonna places like over here onto the site basically doesn't really matter as long as you have no special design. If you want to use my designer gonna offer this into the course, Fif, free to do so. But still you need this image. Now You want to have a button like over here? First off, I want to rename this image to be, let's say drink, image or item image doesn't really matter while you name it as long as you can find it once again, an item holder. I gonna create a new u I button and I can't put this button like on the bottom right corner over here. We're gonna implement the functionality for that later on as well. Place it wherever you like to, but don't forget it needs to be as good visible as possible. Now we need a name or ask me some more numbers into here as well as a name for the item. So again, basically, this is just going to be our buy button. And maybe we can also good into the tanks and name it just Boy. We can also go to best fit over here and change the color to a super black or whatever. The color later on is going to fit into your let's I bought in design. Also, you can resize it a bit up and down. Do us through best fit. It automatically will match as good as it can next one is you can also, by the way, put in funds next one is we're gonna put in a title. So item holder, you I text I gotta send the this make it a blank and bold like this and maybe more. Make it the best. Fit us Well, bring it up a bit and put this somewhere in the centre, off the image, the center of the images basically here. But maybe it's not a good solution. We gonna check this out later on once again, this is the design decision you have to do on your own is going to be late on the title. So we're gonna name it, maybe item name. Now we can duplicate this one just by selecting it and press control de to Dublin. Kate. And then we put this over here. I make a tear to the left and gonna get rid off Bold, Since I just want to have it as normal text. Probably sooner shrink it down a bit, but I want to make sure that I may be resize it up to the button size of somewhere. This is probably going to be our g p s text. So gold for a second. And also we gonna rename this to be a GP as text. Then we're gonna duplicate this by holding down control and press D and drags one down until it matches the next little row. And there's going to be the amount colon something. And then we're gonna name it amount text, and the last one is going to be the coast taxed. So the next item, How much does it coast? Of course, we can calculate this already, but you also want to show the player what he is going to get whenever you purchase that. And that's everything for the item holder at the moment, Of course. Don't forget to rename Ahmad the older Mont X two to be the coast text, so there's no confusion later on, whenever we drag or the items together. 11. #10 UI 2 Scrollability: welcome back to the course in this part. We want to create our scroll ability when we have, like, several items into this list, like one above the other or one under the other. So we're gonna make use of our scroll wrecked and probably also put in the bar for, like, this cruel bar for that as well. Well, maybe not. We're going to see that when you select school. But rat, make sure you create a new U I in it. You can also use an empty game object, but an image is easier to see. That's why I mean tend to use images and I make it like this is going to be also O R. This is going to be the actual grid which we want to have all our content in. I gonna name this one grid. Also when I want to have is a vertical layout group inside of this. Yes, I can see Vertical layout Group is just an element which we can put him by at component, and we can put also spacing in between things. So whatever we are putting into grid as a child offered will automatically be vertical e layout. It also I might want to go and bring this over here like stretch to the side as the other one. And maybe we can also already add a continent size fitter. This content size fitter will try to horizontally or vertically fit content into its size. I gonna choose vertical fits and take many moms size. What is going to happen? It will be super thin. As you can see, there's no height, it zero. But that's absolutely no problem for us at the moment on item hole that we need to add another component called and layout element. This layout element makes sure that it is always keeping whatever we wanted to keep in our case, we want to keep the preferred with and now you can see this is the actual with off my item over here also, what we want to select this flexible width and height. So now was layout element. We can make sure that the design is not that same much changing. There will be one small change because we cannot put it over here, but no worries. We're gonna update it as soon as you see this coming. So now we have the preferred with which is going to be this and the flexible wisdom heights . So it always matches whatever the screen size is going to be. Now what I want to do is I want to create a prefab from item holder. I goto acids and create a new fold, Uh, and name it pre fabs. Pre fabs is nothing. Or prefab is nothing else than a template of something. I gonna select item holder and drag it into prefab swollen. And now I have an item. Hold a prefab with all its current content, however, we have set it up with all its information. Now I want to take item holder and drag it into grit and there will be some weird thing happening. Drag it in now you can see we can see that the black one, which is going to be the grid, has automatically the height. Do it through quantum size fitter off our image over here, off our item holder. But what's going to happen? As you can see, item holder has no waste. So what we need to do is we tank profound with and put it in here or we increase with until we see something, something like We tap in 100 as you can see automatically from the left to the right, we can fill in or drag our image until the docks to the outside and everything looks as it has done before. And as you can also see, the Wiz is not the same as the preferred with. Now. What you want to do, toe item holder is you want to apply the changes to the Prefect, So item hold on now knows. Okay, I have a ways off 380.8. When I now get rid off item holder and drag this one back into grit, it is where it has to be. When I know duplicate item holder, it fills the lots of space. That's good, because this is what our vertical land group is doing. When you go to grit and you want to have a spacing off, say, let's five pixels. We gonna see grid through it as a black background. So we have some kind of divider between those items without any necessary set. Um, yet things over here a five too big or too small for you, you can only stand it. I keep it as ISS. What? You also can seize grid starts and center. We need Teoh. Have grid in the top left corner to start over there into the left. What we need to go to is we go here, hold down, shift and press on the upper left corner. Also we need to hold old and I select the upper left corner into the Inca presets. Now the complete list start on the top, no matter how many we have and fills it from top to bottom. Now we want to have our scroll ranked being scrawl herbal. Now what we need to implement is a scroll wrecked component. Now we need to set. What is the content we want to scroll? In this case, it's going to be grid. So we take writ, hold on the left, Muskie, and bring it in here. Also, we only want to scroll down vertically, not horizontally. And if you want to use your mouse wheel, you can put in scroll sensitivity to maybe 30. No, When we press play, it should be able to scroll with the mouse up and down. It's going to be elastic, and we can also hold down the left mouse key and drag it up and down, up to a specific point. And it always goes back and snaps back to If we have more than that and put a press play again, we are able to scroll anti until we see the last item over here, or until we see the bottom at the top item. So now we can make use off the school well as well as off the mouse. Now we want to implement the little let's a scroll bar for that. 12. #11 UI 3 Scrollbar: welcome back to the course. In the last part, we were creating the school. Ah, stroll ability for our grid or in this case, cruel wreck. Taking care of grid. Now we want to implement some school bar. So what we need to do is we go to screw, wrecked, right link you Why? And we're gonna choose scroll bar from the list. This crowbar is currently going from left to right and has no connection at all. The scroll bar can also be resized and reoriented. In this case, As you can see, the direction is left to right. We want this one to bottom to top. If it's not bottom to top, we're gonna change it back. Also, we can now put it into the position we wanted. We can also drag it until it fits like the upper and the lower area over here. If you don't like this, how broad it is, you can always give it a bit space or light on when you have a game which where you have drag ability with your finger like touch inputs, you want to make sure that this is no too small, so easy accessible for the player itself on the scroll bar. Nothing else is needed. But on the scroll ranked, we need to connect the school bar to the scroll Ranked. As you can see over here, we're gonna have a horizontal scroll bar and the verticals quo bar. We want to drank this crowbar into verticals wall bar. It should automatically fit based on the content seen over here, for example, if we duplicate this even more, it can see the scroll bar resize is itself. If we now press play, we should be able t drank the handle and scroll down with a handle directly until we see the very last point. Why is that so important is, let's say, we are at the game point where we can barely see this, but we don't know if that's more. And if we unlock new items, the scroll bars. Lang's is going to change that the player will notice. Oh, there's probably something more because there's bigger space. And here let's scroll down and see what's going on over there. And that's why I implemented this cruel bar over here. You don't necessarily have to, but you can, and that's everything about the school bar and all its functionality. 13. #12 UI 4 Changing the Look: Welcome back to the course. Now let's a redesign or actually design the item. Hold a bit more. So go to your taxes folder and drag in all necessary data if you haven't already, which is going to be a frame a button. And if you also like to, you can also put in the water tank of the background. This well doesn't really matter. So I direct them in here. I need to make sure that button backgrounds, water, think and frame are selected, and I gonna change them to a strike. To do you are. When you have done that, we can redesign or give our item holder. Now, any design we like, you can design your stuff on your own. But if you are not a designer, you probably want to stick with the iron content I just sent to you. So what you want to do is to go to pre fabs item holder, and then here we have a source image. You might want to go and change this one to be framed. What's going to happen? As you can see, the frame automatically changes. Um, in all other item holders, we have another scene because we are talking to the template, the prefab, and give all its information into this. What you also will notice? Probably probably. It will fit for you. Probably it will not. Is the size off the item might not put directly into the frame. So it may be late on you. We need to go into that. And all of that is once again up to you personally. Ah, if you need to change this item over here like this image field, so it better matches over there because it was reading or designed for a bit bigger that say image style also what you want to goes to buy button and change the button form a u I sprite to be button. And now everything is looking the same. All the buttons have been updated and they know look as whatever they have to be. So once again, you can redesign all of that stuff every time. If you want Teoh, change the text off course. You need to make sure that you go directly in tow, item holder, but in taxed. And now maybe you want to make this one of bold text over here. Then you can do that, But you need to make sure that you apply the changes to the prefab. So all the other ones are going to take this to the template and back from the template in this particular case, also about colors and schemes and stuff. All of that is up to you, and you have to do all of that on your own. Maybe I got into the handle off the scroll bar as well. I'm not quite sure if I want to do this right now, because it might looked yes, strange or not as good. So what you can do is you can take the normal color basically from the handle and change this to whatever you like. Or maybe give it some. Ah, accent, I would say. And you can also do the highlighted color. Maybe put this a bit until lighters well, not like not so dark and not like highlighted actually make it a bit better over here. And maybe in the sliding area, there's going to be another handle and your minds no, in the sliding area. It's not like the background color over here. You might want to change this also to I don't know. Maybe something black or whatever is matching to your likings Once again, I don't go and cover too much in case of design. Ah, this is what you need to figure out on your own. You can even put in your own your frames and images and all that stuff that's all soldierly up to you. Okay? And that's everything about designing all our item holder. Basically, we can get rid of all of these items holder right now, because we have done what you can see is content size fitter is or actually ah, the grit is once again in the height of zero because there's nothing left anymore and we don't need to fit anything in between that as well. Also, the lengths has been changed off the school bars. That is, there is nothing longer than its size off the content in the school wrecked, then, Ah, this size is going not going to be changed 14. #13 Itemholder Script: Welcome back to the course. Now let's finalize all touches in tow. Item Holder. What we need for item holder is a script to connect toe all the images, names and even the pardon. So go to your scripts folder and create a new C ship script and call this item older. You can name it. Whatever you like, since there's no script which is going to interfere was item Holder. What you also might want to do is you want to go to your pre fast folder select item holder and go back to scripts and direct item holder directly onto the Prefect and opened this one up in mono develop or vicious studio. I'm gonna zoom in so you can see stuff better. We don't need starting update. We just need to have a connection to all user interfaces so we can put in all necessary data to it. In that case, most of them are off K off type you I So we need to implement the name space using unity engine, don't you? I for user interface. Now we need to have access to all the buttons and once again, images and text fields. So we need to create some public very Ebel's. The 1st 1 is of type image. It's going to be our item image. Next one is going to be our buy button. It's going to be public, but we don't have the text or this group for it. So I'm gonna command this out, but already put in something like a boy button and just name it. Boy button was a small B. Once again, you need to command this out because we don't have to buy about script yet. Which will We will create this one, probably in the next video. So the next one is We need public off type text, Texas only accessible on the Y. Same for image. That's why we need to implement this name space. And we call this GPS text sold gold per second text. Then we have another public text called amount text. Make sure you don't have any of spaces in between. Those next one is going to be a public text. Khost text. So what? Our item coasts and what we forgot us. The name basically doesn't really matter in which order you put them is going to be public text item name, text and safe. That's it. Now we go back to unity and excess, or put in all necessary data into this, which we have already except the buy button, because that's what we don't have at the moment. So we go toe item holder and our prefects will. Then now you can see we're gonna have all this connect abilities to this. So what we do is from pre fabs. We're gonna drank item image into the same side time. We're gonna take item name and put this in tow. Item Name, text, GPS tax to be GPS text amount, text and coast text. That's everything we need to do. The last thing once again is going to be the buy button. What we're gonna do in the next video, By the way, don't forget to save the scene as much as you can just for the think off security 15. #14 Buy Button Script: Welcome back to the course in this part. We want to take care off the buy button so we create everything already and set it up correctly. So later on, we just need to reveal oil. Let's say unhygienic. One specific function or function name. What I want you to do is go to Strips folder and create a new cease of scripts called by butter, as we named it before in item Holder. Now we have a buy button script and we can open this one up in Morneau develop or visual studio and can put in all necessary data. What? We don't need to start an update, but we need to have a public Inter John and I call it I d. This is going to be our access er later on for what is this button going to talk to? Also, we need to have something. Whenever we click on a button, we want to call a specific function. Of course. Want to buy an item? This is going to be the click function, which we're gonna have if you don't remember later on, probably what's going to happen? CA link. You can commend out every sink clinic function on button the click facts on button need all needs to be always public. Otherwise, you don't have access to it. And here we're gonna do boy the item, Call the function later on onto the game. Manager. We haven't created this one yet by sending in the i d. Checking a corresponding item list and purchase it if we are possibly or if we are able to . Now, don't forget to save and go back to your pre flaps goto item. Hold a buy button and make sure you drag the script by button onto it, probably behind or after the on click event. Also, you want to add a non click event over here by hitting the plus and drag in the same by button from the prefect to the prefab. But be please don't change anything to I D. In this case, if you are not sure if you probably would touch the i D. In this case, you can hide it in the inspector by using script brackets and say Hide an inspector. Don't forget to save and so you will not see I d. But I d will be. Stay public So we can access it from outside. And you don't do any mistakes in setting stuff wrongly up or whatever. This number later on will be overridden. But just in case to keep yourself organized and also don't confuse yourself, you probably have to hide some items or some variables later on. We're going to do this on to other things later on us. Well, and that's everything about the buy button, except for the function we want to call. And what we do is wherever we click on by button, we want to touch by button script and we call the function by an item. That's the one we have created currently. When we click on it, nothing will happen off course because there's no functionality on it. But it were registered that don't forget to save, and we see us in the next video 16. #15 GameManager 1: welcome back to the course now everything or basically everything is set it up so that we can start to create or put in functionality into the game. That means we need to now have a option or a script, which is taking care off like everything. And usually those scripts are called game manager. So we create a new C subscript and call this one game manager usually in a newer versions off unity. There's going to be a gear sign of the hell or symbol so you can see that pretty much easy . Wherever it's going to sit in your scripts folder and can maybe faster or easier access it , I gonna create a new empty game object into the hurricane. The position basically doesn't really matter. I can zero this one out. If I liked Teoh and I drag the new game and it's a script onto my game object. I can also renamed the game manager object if I like to. I can also give it an Aikin so I can see this in the screen, but basically it doesn't really matter. We will usually not excess this over or inside the scene. Let's open gay manager and give our game some functionality. For the moment, I get rid off starting update. So we gonna start recycling and I try to commend out everything as good as I can. Just so you understand what's going on into that? This scripts going to be the most coding heavy in the complete victorious serious. So but I still try to go into that as slow as I can and as descriptive as possible. What do we need if you have a problem and solving problems, Actually, you're gonna need to split your problems into smaller pieces. At first, our game energy needs to know what kind off items do we actually talk about? In our case, we want to have all our drinks somewhere in the correct order to excess them to count them toe, unlock them to instance, she ate them. And also we want to have access to them to do all of that. In this particular case, I going to create a new class which is containing all this information. So we create a new public class and I call it maybe any drink you can name this whatever you like. This class needs to be public. Otherwise, we don't have access to it. And also we have access only to it as long as it is inside game energy. So also, we can only excesses inside a gay manager directly or whenever we are able to talk to the game manager directly. The next one is we want to put in all necessary data into any drink. What does our drink needs to know? The first thing is, how many do we have? So we say, drink public into drink, Let's say amount. So this is going to be the drink. Amount off whatever drink we have, let's assume we have water. And we need to know how many water we have, the next most important one over years. Of course, we need to have access to our drinks. So we create a new public drink, call it drink. So this is going to be where our script herbal object lens into. We're gonna set all of these things or most of thes things up by hand. Or actually just to I'm gonna show you all of that once we're done with it. Next one is we need to have a public bull this bull is a bull in which only returns to or force. We want to have the 1st 1 accessible, the others not. But actually it doesn't really matter. So this is called unlocked. So if water is unlocked, only then we want to. So the container like the item holder for this particular one next one is we need to have another bull which also needs to be public. Of course. Public bull Instance or instance she aided. You can name it whatever you like. I gonna name it. Maybe instance. So that means if that has been incense hated are not gonna Once again, I tried to command it out. So has bean Instant See Ate it? Yes. No. So has bean unlocked. He has No. And also, this is going to be our script table object. And this is going to be, of course, the amount. I guess that's what you need to know. At the moment, we're gonna command stuff out in a moment as well. Like what we want to hide in the inspector and what not next one is going to be. We need to have a connection toe one off our item holders so we never. We only need to access them once that then we have always the possibility to talk to them. So I'm gonna take an item holder and maybe just name it Holder. So whenever the holder has already set the correct one with the one which has been instead created into this, we always have existed. We never need to find it any more, Like game objected. Find la, la, la. We don't need to do this. We just take it once, put it into this list and then where or into this class. And then we put this complete class into a list, That's what we're gonna do it next. So what we're gonna create now is a new public list off type, any drink off course. So any drink, it's now our class, and the list contains only any drinks. So whenever we have a list off, any drink can put in all this information is based on whatever the Internet, where the element is into the course bonding slots. I gonna name this a drink list and we say it's equal to a new list off type any drink, open close parentheses and close the line with the semi colon. One more thing needs to be done. Any drink needs to be a C serialize herbal class. We put in square brackets system don't see realize a ble into or in front off this any drink class. Don't forget to save and let's go back to unity. Once the compiler is done running, we're gonna You're going to see this in the bottom right corner where this little circles, you know, going around. What we can't see now is we have a drink list in the game and the general into our game, and it's a game object and we can resize it to eight. Since we have eight drinks in those strings, we can now put in all necessary data. But we only need to We don't need to have access to instance or the holder or even the drink amount so we can hide them into the inspector. We better de deus we better do so. Otherwise that's probably something wrong. So I gonna put and hide in the inspector in square brackets in front, off drink amounts, instance and told, So we only see what the actual drinkers and evidence unlocked or not. don't forget to say the script and go back and see the change whenever the compilers done running. So you see, we now need to set up all our drinks over here. And that's super simple, because we can ignore all the other other elements in here. What? You can also see the list elements always started zero and goes to seven. Even if we have eight inside. Same for a race. Don't forget that. Know what we just need to do is we put in water in the first lemon and the second said, That's where the numbers now help you out. Three and two strawberry four into apple five cranberries, six blueberry, seven milk and ate like member. This is important that the order in here is the correct order. And also the 1st 1 the water is going to be unlocked. This is everything you need to dio inside the drink list. No, you can't. Expense. The are actually can shrink that together and you're good to go. Don't forget to save and we'll see us in the next video 17. #16 GameManager 2: Welcome back to the course in this part. I want to continue the game Energis script. So please open this one up in mono, develop a vicious studio, whatever you please. And like the last one, we were creating any drink in the list off any drink, I'm gonna shrink this stuff together so we don't need to take care of that anymore. What do we also need in our game? Manager is, of course, something about money. Right? So we're gonna create a new public float money? I got a name. It's small M. So usually I do that only function aims to get a big letter in front, and I can also command it out. Everything about money would be later on. Also gonna have to text fields about money and on gold per second. In that case, we want to make sure that we implement unity engine, don't you? I for user interface. So since this is also about money and going to create a new public text, so we're gonna put in a text field laid on for total money text, something like that and also another public text. And there's going to be a total a GPS text, something like that. So this is going to be once again the gold per second. And that's what we also need to do later on. We need toe add gold for a second. How can we do that? Of course. We're gonna implement this in a moment, and we need something more over here as well. Last ones is everything about the user interface? Basically. So when we need to have is a connection to our game on. Ditto a prefab off type item holders. So we say public game object. I, um we can name it once again whatever you like, but that makes it easier sold for the item holder. So we need to drag in the prefab and off course. We're gonna have a public transform off our grid. So this is the space object. Or actually, the object was the vertical layout groups. Where we gonna put in everything as a child off grid? This is important later on. Off course. I don't want to have this one big. A small letter over here and this is everything we need to do for that. If you like to have your inspector a bit more, let's say, organized in case off the game manager and not so let's say crowded. You can put in some extra interesting possibilities of you so you can see this is everything about the game manager. But maybe later on it's going to rise. Use, have something more inside than I'm going to show you something. Under user interface, I can create, for example, a space or a had A with something head open, close parentheses in quotes. I can name it. Whatever I like to. For example, I can put in user interface in here. If I save, you're going to see the change in just a second where you can see that this interface or user interface is going to be in there. This is just something where you can simplify the view into the inspector. We can do the same over here. We're gonna copy this maybe and put this under the money one and gonna say, OK, everything about money is going to lend in that you can to make it small letters, big letters. You can Ah, I don't know. Put stripes and spaces, Whatever. If you want to have just an empty space you can type in square brackets space. So this is just creating a space and like, an empty line or something. But I don't think you need this. You can also do this stuff inside classes if you'd like Teoh, whatever. Once again, you please. And like, it's up to you. So this is now our game manager, and we need to put in all the necessary information except money, Money. We can keep this now. Probably, Uh, we can keep this now as it is, but later, when we might want to protect it for our cheater games or cheating guys out there. So you might want to put this one into private and only take a function which have access to the money directly. But that's what we're gonna take out. Take care off later on. We want to make sure that the money is later on counting up correctly and we gonna make use of it and see this and the next part. We're going to start to create some ticker so money is going to go up 18. #17 GameManager 3: Welcome back to the course in this part. I want to continue with the game manager. I want to re implement the start function since we're gonna need to industrialize three things or basically start three things first off before we do anything and start, I want to create the ticker. The ticker is going to take care of that. Every second money is ticking up. And it is only doing that if we have enough the amount off items inside our list off any drink or drink list. How do we do this? I don't recommend using update. You can do this, but really trust me, don't put this into update instead of update, which is running like 60 times of seconds. You want to make use often I e numerator called a co routine. So we call. Take care of that. We create i e numerator. Make sure you type this one correctly. Are we gonna give it a name? A function name called Tick. This I numerator when Evers has been started, will run once it's going to be a timed action way can also put in some waiting for something for seconds for milliseconds, whatever and then it's doing and performing its that by stamp and takes care off that all this waiting is going to be made use off. We want our einem aerated to take continuously until the game ends. So what we need to implement is a wild Lupin here, and we're gonna put in an argument which is going to be just true. So while true and while will be always true, we wanted to perform something. So we gonna stay inside the while loop. Meanwhile it through. And of course, it will be always true. Once again, we're gonna we want to repeat stuff. First off, we want to wait one second. It's always the yield return New wait for seconds and in open close parentheses, we're gonna put a one. So we want to wait one second and after one second we want to do something. And once we had done was that we're going to start in the very top. What do we want to do? Us? We want to loop through all drinks which have more than one drink in it and calculate our income per second. How do we do this? We can make use off two things. First off, we can make a use off a four each loop or foretell. I'm gonna make you suffer for each So you learn what it is going to be. So we say for each open, close parentheses and now what we want to loops through is all drink Are all any drinks inside the drink list? So we need to declare at first what do we want Teoh do? So we take any drink and give it a name, maybe a or D whatever. Or we can also name it. Drink. But drink is maybe a bit too distracting. So I just name it D for any drink or for each any drink in. And now you need to talk to the drink list because these are insight thes Any drink types are inside the drink list. So we talked to for any class inside the class list. We want to do something. This means it starts from top and goes to bottom through all the items inside the list, like every one second and do something at first. What it should do is it should check if we have more than one inside any drink off. Whatever it iss like at least one in case off amount. So this one this drink amount is this drink amount is higher than zero. Only then we perform what's coming next. So we say if de don't And now we can talk directly. As you can see, we have access to everything insight, any drink because that's the class we are currently inside. We want to request his drink amount. We want to save that is greater than zero. We want to do something off course what we want to do. So you want to add to money? How do we do that? It's resin simple. We say money. So money is once again the float where we're gonna put our money into money plus equals. So we add to money. Whatever the current amount is, we add to it. We say a d don't. Then we talked to the drink. This is going to be descriptive, will object inside this class. And now we want to incriminate or we want to calculate the income. This is the one we have created in the second video. I guess we want to calculate income in this particular item. We are currently looping through by whatever the mount is. And the current amount is D drink amount. So once again, it is the one we are currently looping strewn with past this into a more calculate income, which is sitting inside descriptive object, whatever it is we're currently looping through. Now we want to round these numbers once again, I like actually, we want to round up money. So we say money is equal to we want again convert this or actually, typecast is into afloat. We're gonna take mass f dot round and an open close Prentice's we're gonna put in money and then we multiply that by 100 after the last Prentice e, we gonna put in divide that by hundreds and that's it. Now, every second if we have a drink, amount off hires and zero, we gonna increment our money. Let's test this out. I gonna get rid off. Hide the enthusiasm, Inspector. Otherwise we don't have access to it and cannot change something inside these numbers. So what I want to do is I go to a drink list. The first element is going to be our water. Once the compilers done, I should have access to the current drink amount before we can start that, we need to start take as a co routine in start function. So we talked to or call start cool, routine, open, close parentheses and inside we're gonna take in, take often close parentheses. Close the line was the semicolon. Every time we start this level or this game scene, we're gonna start to take. Don't forget to save and gets. Go back to unity when we know press play. It should go through all of these elements and give us money. But since we currently don't have anything, I gotta get rid off maximizing place so we can play around into the inspector as well. So you can currently see money does not grow. But if I buy, let's say we buy wondering. You can see money is now taking up by 0.1 every time. And where does that 0.1 come from? Off course. It comes from water because the base income is 0.1. If I have 10 insight, I gonna increase that number by 10. Or in this case by one like we would get 10 times 0.1. Let's test it out 10 and I can see only 3456 only full numbers and now growing Because 10 times 0.1 s and income is going to be added. If we gonna buy a lemon drink if it is unlocked or not, doesn't really matter at the moment because they don't take care off that in Tech. Let's assume we're gonna add one lemon drink. We now get to at the same time because 10 of these as your 100.1 and this one is one and worse one s well, Partick. So we're gonna get to control S L. A g. P. S ever gonna do this by all the other elements as well. We can add one black member and this again See, this number over here grows horrendously because this income is going to be quite high. Well, so our Tink is working 19. #18 GameManager 4: welcome back to the course. In the last point we created Tick in this part. I want to start to update the game, and it just so that is going toe fill all our item holder into the game. But before I do that, of course, I want to make sure that I hide the drink amount again into the inspector. So I have nothing left. Also, before you hide it, make sure you have no drinks left. Otherwise you ruined the system. Okay, Cool. So let me create a new function. I gonna call it It's off time void, since it doesn't return anything. So we're gonna say White Phil list. We're gonna also name and fill Playfield. Whatever your police and like what we want to do is we want to loops, rule all of our drink list items and see who is going to be unlocked. And who is going to be insensate ID and who has a least one drink. And depending on that, we want toe instant e eight hour item. Hold a Priefer. Let's do this. We created fold up. This time, we can also use it for each. But this is more organized. In case of that, if you double tap the tab button after you type four, you're gonna create automatically the complete loop Herbal four loop. So what it does say is it has an end off. I equals zero. So it creates a local, very able off type interview. I and it set us automate 3 to 0 in the second part. It say's okay. Meanwhile, I is smaller than whatever the maximum is. We're gonna increment I in the end. What do we do? Is we gonna do the same but instead off Max, So I gotta tap once again. So I have Max selected. I want to loops road. The amount off drink list don't count. So as long as I a smaller than the amount off drink list size over here in this case, it has eight elements. So whenever I is smaller than eight on this case seven so we can go to the last element without having any overflow, Then we're gonna increment I and do everything repeatedly inside of that until we have done so. We looked through from the very beginning from the first item in this case, it start at water, then it goes down below. So what did? At first, what we wanted to check is at very first. Is this one unlocked or not? If it is not unlike, that doesn't perform quite more. So What we say is, if a drink list in scrap briquettes, I I is a well zero s an indicator so or whatever the number is whenever it becomes incremental, it and so on and so force. Whenever I z increment ID, we want to make sure that drink list I we want to excess the drink amount into this. So it's a bit different than the four each as we created before. Now we look through every item direct Klay and request it's drink amount And if the drink or in this case first we want to check if it is unlocked. So if that is unlocked, only then we want to perform or unlocked mean when we have to set the 1st 1 to be unlocked . Otherwise we are enabled to excess it or create some. So if it is unlocked, only then we want to do the next step. The next step is we want to check if it has a drink amount, hires and zero. So if drink list in square brackets I don't drink. Amount is bigger than zero. Now we gonna put another one, is going to be an or operator, or we have our drink list in square brackets. I don't inst enshi ated or instance. So if we have either ah, higher drink amount and zero or we have been instance, or really only then we're going to do something on. What we want to do is we want to skip this item because we don't want to recreate the same item. Hold over and over. We want to protect it. And to skip this we're gonna type and continue. Continue means it just leaves the loop at this number I and goes to the next one. That's it. So once again, if we have one drink in here already or we have instant she ated the one item in this particular case already. Then we gonna skip this number and go to the next one and see if once again it is unlocked . The drink amount is higher than that and or is has been insane. She ated already. So if we pass this one this statement. Then we can actually go and create our game object. So we say we created new game object. We call this one, I don't know item older and it's equal to and now we want to instant She ate it so we say incense create open close parentheses And what do we want to instance she ate? Is that first hour item older Which is going to be this one, I guess Let me re name this object to be item holder You I so we don't have any problems in here. So the object is going toe The game object is going to be called Item will tell you why that's what we want to incent it now we need to say What's the parent object we want to put it in In this case is going to be the transform grid we have created beforehand. Now we need to send in want world space or local Suppose we want to put this otherwise we have strange Let's scaling behaviors. We want to make sure that this one is going to be sent to be false And in the very end before the semi colon, we need to typecast this one as again objects, shall we say, as game object, you can put the typecast also into the front over here before the incense she ation message That's up to you. So next one s we want to talk to the item hold and put him all the information from our asshole drink list item. We're currently looping in tow, so the first and very 1st 1 is going to be We need to grab the actual item holder script. So we're gonna take the drink list in square brackets. I don't hold us. So this one now stores the item holder, So drink list. I don't Holder is going to be equal to. And now we once again tank the component from the item holder from this game. Object. We have created it the very first. And now what we do is we gonna get its components off type item holder. This is going to be the one was a C shop sign in front the script. We want to have access to the item, hold a script we have created beforehand. Now what we want to do is we want to put in the name off the item inside the item holder as well as all the other informations about the item holder. So let's go through that as quick as possible because there are some lines of cold to come over here. So first we want to check. I'm gonna do a check. If we have discovered this item yet or not discovered me in our amount off drink amount needs to be higher than zero. So if drink list in square brackets, I so once again, the one we are currently looking through dot drink amount is higher than zero. So it doesn't matter. In this case, we have unlocked this already, but the drink amount is higher than zero. Then we want to put in all the sprites off an unlocked one. Otherwise, we want to do the locked one, like with this question marks and maybe no correct information. How do we do this? We need to talk to the holder directly because we have the holder already inside over here so we can call me this and put it in here like I don't know five times or maybe more, and put this all into one line under each other. So First off, we're gonna say holder daunts item image dot sprite. So we want to put in the currents right into this is going to be equal to and now we need to get it from the drink list. I So the one we're currently so dot drink We're gonna take all of that enforced now from descript herbal objects. So we're gonna take and here the drink image Next one is going to be the item text name. So hold it. Don't item name text dot text is equal to And now we take the item text once again from the drink list. I drink so from discreditable object and put this into this s well, so we say don't Ah, whatever the name is Drink name cool. So next one is going to be the drink amount and the amount can be taken from the drink list directly, and we're gonna put in something like that as well. So the holder that amount tanks to dot text is equal to, and now we're gonna put some quotes and put in something like amount colon space Plus and now we're gonna put in everything from the drink amount directly so we can say drink list in square brackets. I don't another drink amount. So whatever is inside that list, next one is going to be the GPS. So And a two hour holder we're gonna put in the GPS text dot text is equal to Now we're gonna put in some other quotes once again GPS, colon space Plus. And now we implement once again the correct calculated GPS over here. That case we need to recalculate this a to this point directly. So we're gonna say drink list ins, grab rockets. I now we excess once again the drink. And now we need to calculate the income. And of course, we need to put in to the calculate income the correct amount. In this case, it's going Toby drink list. I drink amount, and we're gonna put this s and argument over here, and that's it. Don't forget to close the line was a semicolon. And when we need to do is of course, we need to calculate the correct coast or show the correct coast inside this hole to text. So we gonna take Coast text dot text is going to be equal to now. We're gonna put in something like once again, quotes. So everything in quotes will be seen Golan Space Plus. And now what we're gonna do is we basically do the same. We're gonna take the drink, but in this case, we want to calculate the income by and I'm once again we're gonna take the drink amount in this particular item off, whatever the amount ISS every zero off course, the next coast is going to be, Ah, whatever the base prices. So this is everything can try to go over here pretty quick once again. So this is everything what we need to do for whenever we have discovered an image. And oh, are an item already where? What means we all have already per chased the 1st 1 So what we need to do is, if that is not the case, we want to change some things. So I gonna basically copy all of that, which is inside those Prentice ease or curly braces. I'm gonna put an else statement, meaning, if that is not true, this estate demand is not true than this out statement will fire. Meaning we gonna do all of the same stuff over here. But was one difference for the drink name. I want to have this in quotes. No, I need to delete this first, because all the complete doesn't let me. Is that gonna put their here quotes And maybe something like some question marks. Maybe 5 10 whatever you like. And police Also, the sprite over here needs to be the unknown drinks, right? Otherwise, it doesn't make sense, and the rest can basically stay the same. We're gonna still go and calculate the correct one based on the item. Oh, are based on. Yeah, the drink amount over here. Let's save that. And what we also want to do is at the very end after we have set it up everything correctly . Like after this one over here, we're gonna need to talk to the button. So we have a buy button already. So we talked to a drink list in scrap briquettes. I don't. And here we gonna have the whole down don't. And now we need to talk to Boy Button or whatever the name is. But we can to since we haven't said that this one up. So we go pretty quick toe item holder and make this one. Open this one over here and don't forget to save. So it's of time by button. It's going to be the same name as this one. We want to access the I d. So we can send it the correct idea over there. So I go back to my game Anata and I say Drink, let's not hold our don't buy button dots And the buy button contains the i d. And we want to set this one to be equal toe I So the currently number or the current number which were looping through is going to be the item i d for our game. So where later on have excess or easy access? Just through that, I d thrown the buttons. We're gonna talk about that in a bit. And last but not least, to finish this one up, I gotta put in drink list, inscribe rickets. I don't. And now I want to set this instance to be equal to true. So we don't do everything twice. Don't forget to save the script, and now we can actually check it out. How much of that is going toe work? What we want to do is of course I want to call Phil list and start. You can do this or should do this before the tick starting. So we say Phil, list open, close parentheses and close the line with the semi colon. Let's go back into Ah, the unity and see if the compiler has any problems with our setups over here or if we have any typos. If the console is blinking red, you have done something wrong, so check out everything once again. It's not too hard to understand, I guess gonna close the drink list. I hopefully have nothing inside. What I want to have now is a connection to grit, item holder and so on. So at first I go to my grid and take this grid and put this at the transform. Then I go to my prefects folder and drag an item holder into that. When I press play, I should see something, and I get in a reference the no reference we're gonna take care off in the next video 20. #19 GameManager 5: welcome back to the course. In the last part, we were actually is seeing the first item popping up into our written list, but we got in our reference. It's not a reference comes from the item holder, since an item holder, the buy button, has not been set by us. When we need to do is we drag by button into the buy button slots and we're gonna chase safe the changes into the scene. Now we clear the consul and press play again, and then the reference should be gone. Now, as you can see, water has been unlocked, but we don't have anything inside. I guess so. That's why we see question marks. If we go into that, we have nothing inside water. We don't know what's going on, what we also see you, that this has zero coast, which is wrong. Usually that should be automatically sent to whatever the price is inside our script object , which is going to be base price or, in this particular case, the calculated price. And that is happening because I called the wrong function. And here I want to calculate the coast, not the calculate income. Same here. I want to make sure that I calculate the coast instead of income. Don't forget to save. Make sure both lines of a here do calculate coast in the coast. Text. Otherwise it's wrong. And let's press play again. Now you can see the Coast is going to be 15 whenever I want to buy this item. So I need to have a least a money. Well, that's what we want to predict or put in whenever we click on this by button. And we have more than 15 in case of money that we are able to her chase one. Whatever it ISS question mark item. This is actually what we want to dio and discover. But we need to do or put in some more functionality in our by. But But before Can do. We can do that. We're gonna have to put in some extra functionalities into our game manager since we want to access the game energy from any point in the game, we want to make it a public static excessive so it can cold public static game manager and create an instance off that what does that mean is gay manager becomes aesthetic member so we have access from anywhere. But just by calling game in a gentle instance, this is important to simplify our process. Before we gonna have white start, we probably also want to have white awake. Weg is called before start, no matter where it is inside the script. But this is important in awake. We want to set instance to be equal to this meaning this game in the GIA class, this static one is going to be the only instance or in this case is going to be this particular instance. If there are two of them, they're gonna kill each other. Ah, but in this case, we want to make sure that we have only one instance and we can have access to that particular instance from any point once again, them through the game. Make sure you're gonna do awake. Instance equal this meaning Now we can have easy access from the buy button to buy the item . To buy the item, we're gonna have to call a function which we haven't done or created yet. But we're going to do this in the next video 21. #20 GM6 BuyItem: welcome back to the course in this part. I want to create the buy button functionality, so we have something to call from our buy button. This by Button says, since once again, inside item holders already connected and where we want to make sure is that in our game manager, we're gonna create a function which is called from the Bible. Let's create that at first. Since I want to have access from outside, this needs to be public. It needs to be off type void. Since it doesn't return anything, I wouldn't maybe name it by item. And in its arguments, we're gonna put in an inter job and call this I d. Now you probably get the idea off this particular function. I gonna save that and go back to my by. But when I want to buy the button, I want to call gay manager. Now I have the possibility to talkto instance so the particular instance over here and now what I want to call is by button and it requests an I d. And this idea is going to be the i d. We sent over beforehand. Meanwhile, creating everything to this particular by party, so I put an I D and close the line was a semi colon. Now we can close by button, but we need to do one more things to it. So go to the Prefects folder and select the item. Hold the buy button. And if we haven't done this already, then we need to do this. Like if you have not set up the on click event for the buy button. By any item than you, this is the time to do it. Otherwise, you might forget it. Don't forget to save if you have done any crucial changes and let's go back to the game manager inside, the game ended at first. We need to tank if we have enough money to buy the item. If not, we want to have exit this function. We can also give out a DiBacco print message. So whatever something in the U I solder player knows. Oh, by the way, you don't have enough money, so that's what we want to check first. So if junk if enough money comes over here first, Otherwise we once again I'm not able to purchases. So if I want money is smaller, then and now we need to look smaller than now. We need to talk to the drink list, so drink list in scrap briquettes and instead off. Since we don't loop through all these items like the world time and stuff like that, we just requested by its idea because and feel list, we gave it the same ideas, whatever the current position off the item is going to be. So we pass in the i d. Then we request that the drink, like this troop of script herbal object, was a sitting on this and we want to calculate the coast by once again whatever the drink list in square brackets, I d dot amount is the drink amount if we gonna have, if that is true. So if money is smaller than that, we don't have enough money. So we can't say D buck, for example, the log We can also once again show later on a user interface design stuff like that, we can say not enough money and close the line was a semi colon. And what we also want to do is we want to return. Return means we break completely out of the complete function and old off everything. So return means just go back where you came from and just stop this, uh, actual co. Yeah. This complete function over here. If we are passing this one, we want to decriminalize money. So we say money minus equal. So we D crew meant it from the current money. Whatever the drink amount Coast, as some can. Basically copy this complete line over here and d crimen the money over there. Now we need to increments the drink amount. And this is also there are two things we need to take in consideration. First, we want toe unlock this one, like being changing the in its name and the image of the actual drink. And that's inside the holder object. And how can we do that? At first, we need to check once again drink list in Scrabble records. Whatever the ideas don't drink amount. Is that smaller than one? That means we never have purchased this one before. And this has its question mark items and stuff like that. Then we want to change the drink image. So what we're gonna do is we cannot take drink list. Inscribe Ricketts once again the I D don't. Now we talk to the holder, which we have connected to this already. And now we want to take the item. Image starts, right, And we want toe override or change it to the drink list in scrap briquettes. I d dot drink. So from the script herbal object and put the drink in it into the slot. Cool. What we also want to change is the name off the taxed. So I'm gonna copy this line here and instead, off item image dots. Right. We need to say item name text dot text is equal to the drink name over here like that. Don't forget to save. And now, whenever we have done with that, um and only that is the case, we're gonna do this otherwise or as an extra. The next stuff is coming, and the next stuff is the first. We want to implement the drink amount by one because we just purchase one so we can say drink list in square brackets. I d don't drink amount plus Plus, You can also say plus equal one doesn't really matter if you later on 12 projects more of that, you're gonna need to have some more fancy calculations, but also need toe implement the buy button amount you want to purchase over there. So keep that in mind, and then you can pass in the amount over here. Like until the plus plots, so he can say plus equ cool. Whatever. The Oman News. We don't cover this, I guess. But just so you heard about it, next one is we want to change all the text fields to this. So at first I gonna go to my field list and gonna take the last three lines over here was in the amount the calculate income and to calculate Coast gonna close that once again. So it's not so crowded here, and I'm gonna put all of these lines over here instead of I As you can see, we're gonna need to put in i d. Instead, nothing fancy to this, I guess. Just go into it and change everywhere where it's red and wears, and I gonna change all of them to be i d so we don't have any arrows. So we're gonna keep like, everything again. But we updated According toa Whatever we have updated so far Now we want to check if you want to have some unlikable So in here I gonna do update you I in holder. So you know everything about going to be over there. Here, We're gonna decrees money. And now what we want to do is we want to unlock the next drink. And to do this, we need to check if the i d is matching and also not overflowing as well as not too high, actually, as well as if the drink amount is bigger than zero. So what we're gonna do, is it for us? Want to check if I d is smaller? This is important drink list don't count. But drinkers the count would return seven. In this case, it would return aid, but we need to negate that by one number. So we say if idea smaller than drink list of count miners one. Otherwise, we're gonna have an overflow in the very last item. Also, we're gonna put in an end operator so two times the end symbol over here is an end operator , and we want to make sure that drink list in square brackets I d don't drink. Amount is bigger then and now we can play around with that. If you want to unlock it directly, if you have more than zero absolutely possible. If you want to have more like nine possible. Like, for example, I gonna be able to see that only if I have purchased 10 in this case, 10 items before I unlock the next we're gonna play around. Was that probably in a bit? What do we want to do? This. We're gonna take the next item in the list. So we say Drink, list. I d plus one and set this one to be unlocked, equal to true and what we can now do us. We can use Phil list and let it run over it and see if it can actually unlock the next one . Now, at the very last After we have unlocked the next drink, we can actually updates the GPS like the input. And we can also updates I Let's a update money view I as well. But that's part off another that you let's go into the game and check out what's going on over here. I'm gonna press play once the compiler lets me do it. And now we should have fully functional by, but so I go to my game view over here and tried to press it. But as you can see, it returns that I don't have enough money. So I'm gonna go to my game and a job and give myself 16 money 16 because this one cost 15 and I want you to see that we're reducing money upto one. Don't. I'm gonna purchase this on what you can't see. It automatically unlocks the next one was question marks. It also shows him is a correct coast as well as shows. Oh, by the way, the next one you want to buy is having a coast off 17.25. And also, as you can see now, the money is ticking up. Zero pawned one per second because we protest this one. We already seen that the GPS is working also. As you can see, the image gets updated and so on. And so force. Let's cheat some money. I'm gonna give myself one million now just because I can I'm gonna buy some items. What you can't see now Here the scroll bar gets bigger. Whenever we purchase new things. There's something which I haven't said it seems, but I don't have enough money for the next one. So after the cranberry juice, there's one item which has no question mark symbol. So I go pretty quick into my scripts. Blueberry on blueberry does not have anything, so I give it a blue drink. And, of course, the question Mike unknown drink emits take the other ones are pretty quick. Looks good. So you can't see simply and easily we can bring ourselves some good amount of money. Once again, I go to my game image over here, give myself some money, maybe like a two with some zeroes in the end. And then we gonna invest some of these money, actually, and gonna buy some of these over here, and we can't even pro taste. Oh, no, For for that. When we don't have enough money, as you can see, the coast of 3.3 e plus zero eight. Same Here. You can see two points re e plus zero seven. So this is what we gonna get us inside the calculation so later when we might go into these coasts and maybe we're gonna change some of these numbers. But at the moment. The complete system is up and running, and we also get a good amount of money. Meanwhile, we're waiting for more. Also, we can by so many of these items over here, like, just by clicking on to them and reducing the amount of money we're going to get from the other ones. So, as you can see, it becomes even. Yeah, harder and harder. Teoh, earn more and more money. As you can see, we're gonna have, like, a decent amount of coast over here. For each item it grows horrendously in price. But that's what an idol game is about. So we have an exponential gross on all items with yeah, everything set up correctly. 22. #21 Watertank 1: welcome back. Of course, In this part I want to make a possibility to earn some money when we're clicking on an object. This is our resident start, I would say so. We per click want to implement or in cream int our money so we don't have to cheat. But we can click on an object to get a least 15 together, and in the end, we can pro chase the first water. It can help. Meanwhile, we're clicking on this. What? You might want to go us into your canvas and dragon or create a new U I image, and you want to make sure that this is a very top means it underlines every other item. Also, I go to the anchors, hold on old and bring this or settles to a stretch. Now I want to set the image on all of this right to be my background Sprite. You could make use of that as well, or you have your own doesn't really matter. So this is going to be my room image of the here you can design that can make some nice windows in the background, basically doesn't really matter. It's something for the game. It's not not, you know, it's not so important when how you put this. You can also rename this one to be de because it doesn't have anything else but the baby backgrounds. Next one is I want to create another you image. This is going to be the clickable container. So the water tank as a graphic I have already over here, I want to put my strike into this, and I want to set preserve as big ratio. I can make this one as biggest. I like position it wherever I like, and but I want to keep some space to the bottom. I would say Make it also big enough. So the is that the player can easily click onto this gonna name this one water tank. And of course, we need to have some functionality whenever we click on the water tank so we can make use off that and get some money out of it. Let's go to our scripts folder and create a new C shop script and call this water tank. You can name it once again, whatever you like, But for me, want to tank is what it is. A boat. I gotta say it like the water tank itself and drank on the water tank script. Double click to open this one up in mono develop or visual studio. What we want to have us. We don't need Start, I guess. Well, at least we need start, but we don't need update. We want to create our own click function, so the click function is going to be called or of time Boy it and we call it Click. We don't need to have anything else of a hue, but whenever we click on it, we want to talk to the game ender thought instance. I want to go, Let's say directly into money and add one money into this. The point is, it's easier or better for the game itself to protect money and create an excess er to this . So usually we can say, OK, we're gonna take money and add to it, but let's do it different. Let's go and create our own function. So we say it's off type Voight. It needs republic, otherwise we don't have access to it. Then we're gonna take or name it and money, and we can also put in an inter down and maybe put it on. Call it khaliq amount. So whatever the click amount is, or the incoming amount, would we just name it? Just amount. We're going to implement money. So it's a money plus equal whatever amount ISS. The good thing about that is we only need to access that, but we never go directly to money. How cool is that? It's actually to protect money directly and only give it excess over the sanctions. Also, I make a quick note earlier because we need to update you. I in case of money or money you are. We don't have that at the moment. So we need to react, create this one they don't. So since we have this function right now, we can go back to a water tank. And instead of talking to money directly, we call at money and give it a quick amount off. Whatever the clicker mountains, I can also catch. That s whatever and give it any number later on as well. What does it mean? We can create a new local very able are actually a private, very able name it click amount and said this one equal to one. Well, at least for the moment. So this click amount is going to be this click amount. Whenever we click on it, we're gonna add money to the game manager that's tested out. Actually, at the moment, we cannot click onto anything, or at least not onto the water tank. I can tell you we can go into this. I'm gonna open the game manager and you can see Okay, we're gonna have money over here, but we don't talk R Release or Ashley check for this particular click because we never call the function. And since this is a graphic au I or an image, we need to take something into consideration. Of course, we need to have an event which is triggering our click or actually seeing or visualising over click. How do we do this? We gonna add a new component. It's called event Trigger. We can create or add a new point click. And this point of click once again is another event which you can add. So we add one more, one more. We're gonna drag the water tank into this. It's basically like a button. And now we're gonna call water Tink click. Let's play. We want to make sure that we select the game manager sick. I will money amount. Whenever we click, we're going to see that we add one money. I can't click fast and ed even more money. Whenever I have No. 15 I can purchase my water so I don't need to cheat anymore. And I can actually take this water tank into consideration and add by clicking once one coin, gold money, whatever it ISS onto my yeah, into my business. And then I can pro taste my first water drink. Let's any made this thing because we want to have some let's say visuals as well. 23. #22 Watertank 2: Welcome back to the course in this Bart. I want to animate the water tank whenever we click on it and react and probably do even more things to it. So But for now, that's just trigger an animation like a scale down and scale up. Whatever interes a short amount of time because people are tend to click quite fast. We don't have much off a time or timeframes. Select the water tank over here inside the canvas and go toe window animation Animation. What you're gonna end up is with this animation window. We want to create a new animation clip for this, But before we do that, we go to assets new folder and create an animation folder inside this animations folder we're gonna create in you scale wanted tank animation. What you need or what do you Ah ah, how you name? It is absolutely up to you. Scale Want to tank and safe. Now we want to add one property and the property is going to have time wreck, transform scale. Click on the small Plus, Then we can open this and scale this in all three axes. First off are gonna take all these points, which are the key frame so that when I bring them residue on to something like 0.5 holding down control lets me zoom in quite a bit. So I can't see these key frames that even better. I want to bring this even more to the left to 0.4 When I go with the time frame to 0.2 I can put the skate value in here. So what I do and change this 1 to 0 point, let's say nine and all three axes. You don't want to put it too much since otherwise it might look a bit strange. Now we can actually close that. Or what we can do is we can create another clip. This one is going to be a scale I want. Ah, Idol. I don't want to have an idol state where those actually these changes are not getting Yeah , changed actually. So I add scale to it and that can keep the key frames that they are Now what? You want to go if you don't have the animator we know you want to go to window animation animated What? You can see is actively. This one is going to be the main one scale water tank this scale wanted. Think Idol does not So right. Click on this and sit this one as a default state. Now when we want to do is whenever we are clicking. Meanwhile, the sin I'll say we want to make a transition to the scale and then transition back without any problems. So right, click on that. Make transition to scale water tank. Also, what you want to do is to want to create a new event trigger over here and call this one, maybe click. So when we are no selecting it this little transition Aero, we can transition toe one or the other things. First off, you want to make sure that has exit time is off, You will get a notification. Transition needs to be at least one condition. Otherwise exit time will be developed. In this case, we're gonna add to this conditions list and put in clink. So what? Haven't we click? We gonna goto want a tank whenever we are No done was that we want to create another transition back to the Isle state without any transition. So now You can also see there are four klicks scene of the here into this transition list. So what does it mean? As this one is set to be Lupul. But we don't want that. So we go to animations, scale, water, tank and deactivate loop time. We now go to this transition. You can see there's only one scene and this one and only one scene in this one. The next one is You want, of course, to trigger this and later on, fiddle around with the transition time. So how do we trigger that? Of course. We need to go into the collect function for our little I can over here, or our little water tank. So opened this one up in model developer visual studio. And wherever we are, adding the and this amount or the stuff we want to also animate don't get rid of this command. Why don't want to do this? You want to talk to it, but to talk to it, you need to have a connection to the animated component. So first off, we're going to create a new animator, call it and, um then when we want to do this and start We want to actually get a component from our current game object and put this into an um so Annam is equal to get component open. Close friend of this car trying a briquettes and the type is going to be any major was a big open close. Francis's behind it and close the line was a semi colon. Now we can talk to Annan or this animator component and trigger the click so we can't say Annam dot set drinker Open close parentheses inside it. What? So have a string name. So in quotes, we're gonna type Click. This is the name we gave into the properties window off the animation set trigger. Once again in this animator component in para meters, we created a new trigger and named Click. If you are in layers, you want to go to para meet us So whenever we trigger that it's going to go inside, finishes up and goes back into the idol stage. Since this has no exit time, it doesn't wait until Idol is completed. So it goes directly whenever the click appears. Let's test it out. I gotta press play when you have the water tank selected, you can even see how the triggers working. Whenever I tried to click this, nothing happens. This might be doing through the fact that the transition time is too long. So what we can do is inside. Over here, we can reduce the transition time. So since scale is not that much, and also there's nothing to go and tradition too much until we can rather reduce it to a rez. A small number over here, probably you can also the transition direction can. Maybe it's set this to a rez, a small number when we know press play and try again. Nothing is happening. When I trigger the clink over here, you can see that the click is going to be performed or actually the animation for the clink . Whenever you're in the paramedics window, I gonna go and save my script. Since I think I forgot to say the script and try again. There we go. Now, whenever I clink, I gonna get this little animation, but it's taking quite some time until it gets recognized or actually get back to this original state. This is because this transition time is way too long as it can see over here as well. You can zoom in just by using your mouse wheel and to drag around with the most button. You want to reduce the transition time over here to a super small number, maybe something like. Okay, whenever the scale is done, gonna bring this a bit away. I want to maybe reduce it to a rez. A small number over here. Make sure you don't overdo it because it can happen that unity gets stuck at a specific point. Maybe they're fix it already. What is the transition time is probably too small of the officer. It is a bit strange or even the exit time is a bit too high. Whatever. Anyone to make sure that everything on here, like when I set the exit timeto one then you might want might not have too much trouble on that Also, maybe the transition time does not have to be too small. That's s a dot again. And I perform my clicks. I can see I gonna clink and it's almost instantly releases it. After I release my click, a swell can also try to superfast they click this You can see the reaction time is absolutely fantastic. So just was that small changes where the trigger time Oh, athlete, the duration or the transition time is going to be reduced. We have actually festive resonance inside our clicks. 24. #23 Click Popup Text 1: Welcome back to the course in this part. I want to make it so that I have some floating numbers flying upwards. Like whenever I click, this son can see whatever the click amount is like the click. Yeah, the money we're going to get per click is going to be seen and as flying up and off girls going to destroy itself after a given amount of time. We can do this by doing several things, but first we need to create some text element which is going to take care of all that information. First off, let's create the text element. So I go to my canvas, right? Like you. I text this is going to be my pop up text pop up text, you name it. So you know what's going on? Was that so in here? What? We later on one to have us once again a big number of going upwards. I want to go toe best fit and maybe are gonna give it a blue tint. So fix or fits our design a bit more. Whatever in them or whatever color you set is up to you later on. You can also post code for example, overwrite this number. I also want to make this one bold and I want to send to this one. I'm gonna put in any number, maybe a plus one. Also, I want to make sure that I drank this. Let's say apart a bit away. So I can't see how big it ISS. And maybe I can optimize the size just by dragging this one up and down over here. If I think that is going to be a good size for my number so the player can see Okay, that's what he gets. Then I'm good to go x one in the cameras. I want to create an empty game of decked, which just contains a wreck. Transform. And so I'm gonna take the public tax and make a child off this game object. And of course, I want to send that this one to it. I take the game object and drag it away a bit so we can see what's going on in this particular case. So this game object tires. This more frame over here when we want to do, is we want to animate the pop up text. That's what we need The game object for like upwards. Also, whenever this at a specific point, I want to reduce Alfa 20 as well. So we don't see the text anymore. And once the animation is completed, we want to destroy the complete pop up text like including its game object. But we want to make it only so whenever the year animation is done, we want to do is we want Teoh rename this one, Toby Probe up. Ah, just maybe pop up. I don't know. Um, maybe it's a public game object. Whatever. I don't want to go to my pre fabs folder and drag it inside, so I have a complete set up over here. We're gonna need some coding for that as well. So for the text, I want to animate the tanks inside the pope up game object upwards at first. So what I need to do is I select the tanks, go to animation I created you pull up text animation. So I go once again to my assets animation and I name it Pope up text. So the very 1st 1 is I want to move this one awards so I can go to record and record the animation, for example, to go half a second and go to a record. And then I direct this one up. What's going to happen? It's creating automatically in angered position onto this. Why? Well, you the other one's gonna stay default or just missing, so they're gonna default out this way. So as he also can see over here and the inspector, it only changes its position. So what again, does to complain this and see if that is fast enough for you? I guess it iss so half a second and going upwards like a bit over the game Object nights. Let's say this grid piece over here also, I want to reduce Alfa so I gotta add another text color property and in this case, I going to get rich at first off R G and B, so I can tempt them later on, probably by code if elected. So I'm removed thes three properties by going onto this little knobs in the very end. Over here, remove property. You have to right click it and then you only have Alfa. You want to go to the center and take this knob from Alfa and bring the CIA. Now you want to go to the last part. I want to reduce l 4 to 0. Just type it in. So what? The animation is going to do it going upwards, and after the half of the time, it reduces Alfa and goes back to nowhere. Or you never see this anymore. Pretty decent. That's what we need for our little animation. Now, we also have only made a component over here. Also, we can see this in the animated. There we go. This is our pop up text, but we don't need to do anything for this. We just basically can apply all the changes to the prefab and could even get rid of it. But we need to do some coding for the pop up taxed so it deletes itself after a given amount of time. This given amount of time is, of course, the playback time. We are after 25. #24 Click Popup Text 2: welcome back to the course in this part. I want to make it so that the pop up text is destroying itself after a given amount of time and also shows the correct info later on, depending on what has been clicked. What we need to do is onto our public text. We need to create a new script. So first off, we go to our scripts folder, created new See Chap script and call it pop up text, of course, onto the pop up text directly. Whenever the compiler is done, you want to drag pop up, text onto it and, of course, opened this one up in mortal develop or visual studio. Actually, we don't need this her need to have this one on pop up text. So I gonna remove this component by right clicking on the gear next to it. We need to have this directly on the game object. There's this better and easier to set up. We don't need updates so we can get rid of it as well as all the commence. We don't need those. We need to make sure that we are using unity engine dot You I otherwise we don't have access to text elements. Next one is we need to have a connection to a text field inside this as a child. So we say public text, pop up text. Also, we need to have a connection to the animator component so animate, Uh and, um, you can name it whatever you like once again. Instead, we want to at first initialize Annam. So Annam is equal to get component in Children. And since there's only one, we only need to look for one particular one off type. And he made it only close parentheses and close the line with the semi colon. No, we want to grab all info is about the animator clips. So we say animation clip info is going to be This one is an information about the clip being played and blended by the animated. This is going to be off type array. So we need to put in two types off square brackets and then we name it may be in for, and we set this one equal to an m dot and now we want to get the current any major component clips. So we say or tight and get current animated clip info and which one do we want to get is only the one on layer zero. So on the base layer or no want to do is whenever this clip has been played this one specific clip, then we want to destroy it. How do we destroy it? We say destroy open close parentheses. We want to destroy this game Object after a given amount of time. And the time is measured by info in square brackets. Zero don't clip don't lengths. So whatever the lengths off the caliber is after that, given amount of time, we want to destroy the pop up text game object. So pop up itself. Also, we want to display the correct amount. So we need to have a public white. So let's say info or whatever we're gonna put in any amount we need to call this laid on from the water ting whenever we click it. So we plant in pop up text the text is equal to I put a plus in front of its into only add to it. We're gonna put in the amount which we're gonna send into the show in full information. Once again, we're gonna do this from the water tank whenever we click it, and we're gonna instance she ate it so that we're going to see it in the full color as we like, and please. 26. #25 Click Popup Text 3: welcome back to the course in this part. We want to make it so that the text is actually popping up whenever we click the water tank . Also, what we need to do is we need to take our prefab from the pop up text and put in the pop up text text directly into the text field. And, of course, don't forget to apply the changes to the prefab in the water tank. We no need to make sure that we are able to create pop up text. And so it was the correct click amount, like over using the show info amount. How do we do this? At first, I want to get rid off the public tax since we don't need this and we're going to open up a water tank script. So after we're setting the trigger, we want to create a new game object in this case, the pop up text prefect. First off, before we can do this, we need to have a connection to it. So we create a new public game object. We can name it Full bob text prefab. So we know what's going on and what it is Now. We want to do it. After we click it, you create a new game object. You can call it any pop. What we need to do is we need to instantly it this one off course. And what do we want to insensate? Is the pope up tax prefab? Then we say comma. And then we can already set the actual parents so we can make use off this transform. So this newly created one is going to be child off the water tank. So we don't need to take care off canvas and stuff like that. And of course, we want to set this one to be falls in the world space, and then we need to declare it as game object or typecast. This one s a day game object. Now we need to set the transform position or the position off the problem tax. Where do we want to position it? So we can say it pop dot trance on thought position is equal to wherever we have collect. So input don't mouse position. We could also use at the camera World Space point. But actually well, we don't need to since we don't or actually currently we are not inside the three D space. And actually, it doesn't really matter for that. All we also want to populate is, of course, the pop up text directly sitting on the pop or insanity ated game object. So first we need to talk to it. So what we'd say is pop dot get component and where we need to put an is, of course, the type off the script. We want to talk to its pop up text. It's a script name. Open transparency is dot and now we can talk to so info and implement the click amount. So we call the function directly. You can also put this twice into, like first get the component, then say pope dot whatever it is and show the info afterwards. But this is going to be just one line. A pretty decent Nothing fancy was that don't forget to save. Also, don't forget the safe pop up text. If you haven't already insane for your seat. Now what, you want to do it? Whenever the compiler has done running, we gonna put in the pop up tanks prefab into the water tank script. So, as you can see over here is a problem. Text prefab. You can also put some stuff together so you can probably see this been better, as you can see here. Want to think we need to go to a previous will the and take pop up and bring this over here Let's test it out. So I press play and whenever and wherever I play click this We're gonna get the animation as well as these popping up numbers. Something is a strange and somehow some flickering. With these numbers, this flickering might come from the animation off the pop up text directly. So what you want to do is you want to click it inside your animations holder and deactivate loop loop time, so I'm gonna go to maximize and play and check this one even further orbit more So taking care off a loop time, Just decrease the stuff. And we don't have this of back flicking or black flickering to this point. Usually it should be deactivated whenever the clip has been ended. But as you have seen, sometimes thes flicker happening Good. So now we have all the pope up tanks whenever we click. This wanted 27. #27 Money UI: Welcome back to the course in this part. I want to create a small bar. Where will our money and the current GPS is going to be seen in? What you can do is again simply once again, go to your canvas. You Why? And create an image Going places image wherever you like to. This is going to be just my place. Although my bar well want to place all my information's into, I maybe want to snap that So that is going to be at the corner position over here and maybe does not Ah, yeah. Take too much space if we need more later on onto this image which I can also tend to our into any color, I like to maybe to fit my whatever design I have and so on. It's the forests and maybe not too shabby. I don't know. Once again, designers always up to you we want Teoh name this one bar or money bar, whatever on under that as a child are gonna add a taxed. I want to make sure that I make this one best fit. Maybe give it a black color to see it better. Doesn't need to be bold, but you want to make sure that it's least best fitting. We can maybe places an upper left corner. I can also bring this to the various here. Far right. Public ate this and bring this one in the second row. So the first text over here is going to be my money text one something where all my full money is going to land in sight. So maybe I gotta make a total money or something. Text over here so you can't see what's going on. 2nd 1 is going to be the GPS text. It's going to be the total DPS or in this case, once again, total gold per second. And we have that. What we need to do is we need to connect these two feel to our game manager. And as you can see, we already have created the slots for those. So we just need to drag him in. Money tests goes into a total money test. GPS takes goes into total GPS text. Now, we need to have some functionality to actually talk to these numbers and give out the correct amount. How do we do? This goes, would go to a game manager and create two more functions which are taking care of that. 1st 1 is we want to update the money. You I we want to do this on several positions. I would say so. First we create a void update money. You are open, close parentheses and in curly braces. We're gonna put in our total money text dot text is going to be equal to whatever well we like in this case. Maybe total money, colon space plus And then we put in money dot to string. And now we can also put this one and two a decimal or in whatever we want to have over here Currently, there is, like, this end one which is going to give us commerce and points at quite spots. But I want to have two points after the coma. So I said, and to this is everything we need to do for the money. So, no, we can put in money or update money. You I like whenever we approach chasing with something so we can just call update money. You I close parentheses goes the line was the semi colon. So whenever we purchase something, we're gonna update money. Why? One more thing is probably what we haven't seen over here or what we don't like to oversee is want to copy this and put this also into the update money function, as we already have commended out over there. And the next one, we're gonna create the GPS. You I functionality and centers into that as well. 28. #28 GPS UI: Welcome back to the course in this port. We gonna finalize the total money and import the DPS. Total money just works, but there's one floor. Whenever we start the game, we don't see whatever the amount ISS, we only see that if we click once on to this bar over here, whenever we make changes is going to update. Also, when we purchase, we're gonna decrease it. But we don't see this on start we want to do is we want to call this function update money . Why also in the start function? So we go quite up after we filled the list, we're gonna put update you. Why? Money And then the very last, we're going to start the core routine. We know Want to do it. You also want to create a GPS calculator? This is going to give us the correct amount of GPS oracle per second a pen, depending on Well, how much we already have over here. So what we do is we create a new void, calculate GPS, open, close parentheses, and we want to do this. We create just one float number. We can name it all GPS, and we set this 1 to 0. Whenever we are initializing local variables, we need to make sure that they have at least anything inside off these local variables. That's what we need to set this 1 to 0. Now, once again, we go back and create a 40 each loop. We can also use a full loop. Doesn't really matter. But in my case, I'm gonna use for each. Whatever you like. You can make use off. What we want to have is, of course, the same stuff as we have done before. We're gonna want to tank for eats, type any drink, give it an A in drink list. So we looped through every drink or any drink type inside the drink list. Want to do something? We want a first check if a don't drink amount is bigger than zero. End of that is the case. We want to calculate all GPS, so we say all GPS plus equal a dots. Now we're gonna go to drink, don't calculate income, try a don't drink amount, which is going to be the number we need to calculate this. And now we update the text value according to that, so we can say total GPS text dot text. It's equal toe quotes total a GPS or gold per second colon space plus all GPS done. You can also convert this one into its ring and do some comments and stuff like that. But usually those numbers are not. So let's a freaky and fancy and flipping around. That's why we only do this over here inside the money part. Now we need to calculate the GPS at whatever time we update that in this case, we go to our by item Very top, very bottom, where I already have a command update GPS You I So we're gonna put the function name into it, and the line was a semi colon and we're good to go. Also, we want to put this into our start message, so we're gonna call calculate GPS over here before we start the actual tick. Don't forget to save. Let's go back into a game and try it out. Of course. So once everything is done over here, we have zero GPS over here, which is actually fancy. Since usually the text should be updated correctly, Toby zero. But since ah, this four loop is only counting or Ashleigh doing the tax change of a here inside the drink amount. We're gonna need to do the stuff after the for each lobe, I guess. Meaning we need to tack is that is not the case. Like if none of these is going to be hired them a zero basically were begin and the end check. If all GPS is still zero on, then we're gonna give it a usual one. So in here, I can put in an if statement if all GPS is equal to zero. So nothing has been changed. After we were looping through all of that, we're gonna take this and put in the correct one. So now it should change, even if there's no per chase at the very beginning. And she'll change it to be GPS or total GPS is equal to zero like this? No. When I click on that and go and you get like, 15 and by one, you can see the total DPS s No. 0.1. We can no update everything over here and get even more. And total GPS is 0.2. What's not going to happen is the Whenever we're looping now are currently money after the money text does not change even if we should have a 0.2 over here. So we need to update the money text also inside. Well, I I would take co routine. So whenever we are done with a ticking up the money and stuff like that, we want to call update money. You Why as well. So we update that whenever we add any kind off money to it, don't forget to save. Don't forget to say the scene as well. Whenever have been major changes and press play. Now I'm gonna get 15 off these coins or even one more. And now, whenever it is inside, take it also is sticking up. Meanwhile, we are clicking. It's still updates correctly, and that's what we want it. So now we can't even purchase more. And also we can unlock the next drink, meaning I can click until I have a coast of 100 over here. My total money. That's what the game is about. And that's what we were creating and pro cheese the next lemon juice. There's one more thing I wanted to recover or wanted to show you is the unlock ability. For example, in here where we unlock the next drink inside the buy button. We set this one to be zero. If we want to put this in the higher number, like when you have at least purchased five times or four times Oh, in this case, five times one item only. Then you want to unlock this. Don't forget to save when you do stuff off that like stuff off these changes. But you don't necessarily have to do this. I just want to show you. So Meaning? I gonna get 15 coins, but you can see I do not unlock this. Know what I know? I need to do the need to protest like four more times water until I have an amount of five . That's what this unlock ability is for. So if you want ah, actually give your players somewhere hints as against the I ever amount of five now. No, I need to protest this five times to unlock the next one. So if you want to give the players on your player Izabal ability to do this, of course feel free to do so. But probably you don't want that because you want to attract them toe purchase even more stuff and so on and go higher and numbers and stuff like that then and only then it makes more sense to keep this number s on zero in the by per chase or buy button script. Don't forget to save everything and we're good to go. 29. #29 Save Function: Welcome back to the course in this part, or Ashley in the next parts we want to go into saving and loading our scene. Actually, what do we need to save? Is only a couple off numbers since we designed it so that we can easily excess everything over the game. Manager. We also know what is going to be inside the drink list. We only need to store some small amount off numbers. The first number is of course, how much money do we have? But also at the same time, Depending on how many drinks we have, we need to store the drink amount we already have purchased. Saving in total is not going to be the hardest part over here, but loading since whenever we want to load something, we need to make sure that we deliver oil necessary data back into our engine and we would go overloading only if we're starting this particular scene. Otherwise, who will have some problems with filling and you're actually clearing the list away? So that's what we're going to start with. We're gonna start with saving everything we want to do is we go towards groups, hold on creating news teashop script called Safe or Say Float. Basically, we can put in everything in yet into the script, like loading and saving directly the Sony and the once again the saving and loading is not the hardest. It is more like about how we are going to do this. We have several possibilities to safe. We can use something called beina reform hitting or XML for mating like, which is basically the same into adjacent file. But we can also make use of player preps, clam proofs of the easiest, simplest but also same way, most unsecure way too safe data. I gonna show you not to save everything in one key like a player. Pref will create a key into your registry files or on this on the device, wherever it is. But what I want to show you where we can put all complete data, we really won't need to save into one player Pref data. Otherwise, if we have like 20 different items and we put them separately in different keys, it does make sense because it would take too much time to create or override these keys. First off, to have access from everywhere I want to make save load, going to be a static, very able or aesthetic script in dance, gripped, we gonna name it. So that is going to be a static, class safe load. And we get rid of mono behaviors instead. Would not work. What does it mean is we don't need to put the safe load script anywhere in the scene. We not just need to have it somewhere in our build. So what we're gonna have is just an empty Senate class. We could basically put this wherever we like to, but doesn't actually really matter. I want to have it separated. So we know what's going on in this particular script. So now we can talk this by just talked to, say float and then talkto the function we gonna have in here. Since aesthetic classes require also aesthetic functions and aesthetic members, we're gonna need to take care of that as well. Let's create the safe function. I gonna explain it. Meanwhile, we are creating it first, it needs republic. Otherwise we don't have existed. It needs to be as set before static. Otherwise, we don't have access to it either, as well as we. It is a type void, since it doesn't return anything and we can call it maybe just safe, open, close parentheses. And of course, we're gonna put in those are kulaib races over here like a usual function, as we have done before. Well, we know want to do is we want to put lying all necessary arguments or very Abel's inside this class or into this function. I gonna write some comment of a year, so you probably understand the better. Every amount in our drinks is an integer, and we can give it a number. For example, just one or D one for drink one. We can also name a drink. One basically, how we do this doesn't really medicines. Once again, this is going to be the drink amount off each item from seen from the game manager or we need to do is from the game manager. When we want to save, you want to go through all possible items and sent them over here into the safe yet into the same function. So what we're gonna do is we create an inter John, we can name it. For example, D one. This is going to be once again the integer for drink one about the drink amount. No, I can copy that. Like eight times 2345678 This sounds strange, but works horrendously good. We can also lose through something and get all the numbers on our own. But probably you're better to do this over here. If you laid on a more or less items over there, you need to make sure that all of these are correctly sent over. And the last thing I want to save is of type float at the moment, which is cool is our money amount. So whatever the money currently is going to store this in here as well. Now you wonder why the heck are we having interjects and floats? Because the saving is going to be a specific safe process. I'm gonna show you. Why? Don't want to do is I want Teoh say I call player preps and I want to set a strength. So in a string I can put in any key will value or any key which is going to be our excess er later on to read the data are gonna name it may be idle safe if you want. Teoh. Yeah, Let's say a make it a bit more secure. You probably name it something else, which nobody can actually figure out what's going on. But well, does really matter for us. At the moment over here, we gonna have a string value, like the complete value we want to put in this particular player Pref. So this is going to be all the numbers, like all the drinks amounts as well as the money goes into the string value. And we need to put in a separator between those so we can later on read the string better. How do we do? This, of course, will be put in as D one plus. Then we're gonna put the quotes and a pipe in between this pipe is going to be our separator. I gonna put another plus over here, Meaning we first take an Inter John D one that we put a pipe. Then we put the next interview. It will be D two and so on. And so force, including the money. So it could be this port I'm gonna pace. It's, like, a lot of times in here once again. So this one is going to be d two d three Defour the five 86 de seven int finally d eight and at the very last over here gonna delete this was a bit too much. I gotta put in money. And this is everything you need to know about saving basically. So later on, we just need to call this particular say function fill in the or all the needed data, and then way actually have stored it completely. To actually visualize that are gonna put a debug line over here. Something like D back don't log and imprint in quotes are gonna put in game Safed. This is just so that I can see if a game saving is going toe work later on. 30. #30 Load Function: Welcome back to the course in this part. We want to finalize a safe load script we have started in the last video. So we're gonna be able to load something or actually this particular player press. So please open this one up in mono developed over visual studio and let's get into it. First off, we create a new public static function. We gonna call it load so public aesthetic Boyd. And now we name it Load. The downside is we don't really want to have it as avoid transient, since we in this case you want to return something and what we want to return is a string. So this complete idol say, string as it is, we want to the return it. So instead of heaven avoid, we're gonna put in strength somebody we can later on when we call Load returned The complete string were safe before. So what we know want to do is we want to catch the data. So we name it. String data is going to be equal to, and now we read from the player press. So we say plan proofs don't get string. And what is going to be the key off course. It is going to be idle safe like so don't forget this And the line was a semi colon. Next one is we want to put in also a debug line over here so d back don't long. And in here we want to say game, load it just to make sure later on em debugging. We're gonna know that this function gets called correctly And since we want to return a string, we need to say return and what we want to return is data. So the save data we have actually stored in this particular strength we can also simplify that instead off putting this one first into a data we can directly say return, play, press, don't get string Idol safe. That would work the same way. Don't forget to say the script and we had done was safe and load. The rest is going to be done in the game Manager in a bit 31. #31 Saving: Welcome back to the course in this part. We want to start to actually safe the game. First off, we created the Safe Lords. Groot was all necessary information in the game. Miniter, We know one Teoh. Make sure that we load or as they do the same thing at a specific amount of time. For example, what we can do is we can used a function which is actually doing all of the stuff for us automatically, that means we can basically do something like an out of safe. First off, we need to have a faction which we can call to save the game. Also, to safe the game, we're gonna need to put in all the necessary information. So first off, we create safe the game on what we need to do in the years we need to fill in all the necessary data. Meanwhile, we are calling save loads script over here. To do that, we can simply call safe load, don't safe. And as you can see, it requests D one until eight and money. So that's what as an argument. So that's what we're gonna put in over here. So we call once again the safe function, we open close parentheses and now we're gonna have to put in all necessary information. What we need to have is like every drink. Amount needs to be inside the safe load function over here. How do we do this? We're gonna go to drink, amount or drink list in scrap briquettes. Zero. And now we say, don't drink amount. Then we have to say, OK, we're gonna take a comma in here. Now we can put in all the other ones as well. We can also make it so that we can a Lupus through the complete list and fill the data accordingly. But that's what we need. Or where we would need to catch, like all the data beforehand in this case the best way. Probably, Even if it is a bit more off work, we're gonna put all of it by hat. So I'm gonna put, like, a three or four at first of a here. So and I want to make sure I start with zero, since element zero is the first element in the list and the last element is going to be element seven. So now I'm gonna pasted even Maurin here. So I have the 1st 4 and I again basically copy all of that. You can also, by the way, go into the next line. Maybe you're gonna pace the complete content over here. Don't forget to put a comma in between those. And now I'm gonna have to go upwards until I hit number seven. Once again. Later on, you might want to go into loops rule and catch the number somewhere. That might be a bit, Let's say more efficient to that. For now. We're gonna keep it as that we know for God is, of course, we need to put in the float money. So we do that we're gonna put in money sometimes basically everything we need to do to do saving. We know. Also can do is we create an automatic saving for us every minute or every two minutes. But that is up to you. If you want to use that most off the time, it is absolutely needed for most of these clicker games. Don't forget to safe. And then the next one, we're gonna do the order safe 32. #32 AutoSave: welcome back to the course in the last port. We were actually starting to create the safe functionality in the game manager. In this part, we want to create all the safe. Although safe is nothing else than repeatedly calling function. For now, we're gonna create a new void and name it auto safe, open, close parentheses. What all the safe should do is it should call safe game after a given amount of time. So for now, we say, save the game, open close parentheses and close the line was a semi colon, but also, we want to repeatedly do this. In that case, we implement a functionality called Invoke. We can invoke a mess it after a given amount of time. So the message name needs to be a string para meter. So it for us, we want to invoke out of safe. When I gonna highlight that and put some quotes, I gonna have it automatically set up. That's probably setting. You might want to check out later on in visual studio or mono develop for order completion . Now we need to set a time how long the invoke message should wait until the repeats or the safe. In my case, I'm gonna put in 60 F once again f dense for the floats, so make sure you put it in. If you have some, let's say common numbers. It is important. Otherwise usually doesn't. But you probably want to learn and always do efs after afloat. So you always room. Okay, this is going to be of type float Now we need to call out a safe. How do we do this? Of course, we can't do this directly and start so the first safe will be automatically whenever the game starts. In this case, we can, for example, start the 1st 1 after we have done a tick. So we call. Although safe, open goes parentheses, close the line. So once again, on start, we call out to safe that calls safe. The game waits 60 seconds and saves the game again. Whatever stets are inside, you can always go back to unity and make a check. The check will be in the consul if you have done the setting so that you can see the consul want to get rid of maximize and playing. The first message you should see is game, Safed. That means I was saying game is no safety in its current state Was the current total money when we know would wait a sec or two or five and we're gonna do some damage over here, Or actually, we collect some money. All of that will be Safed after once again. Another minute you can reduce will increase a safe timeto whatever you like and police. But I gonna wait until the next tick is coming into and the game is safe the second time so you can see that out of safe is invoking correctly. And you might want to go on, check this one out on your own as well as you can see, the game has been saved another time. So whatever, we can't be having money. We can try to remember 22. Then we gonna be able to load this amount in one of the next sessions. 33. #33 Loading The Data 1: Welcome back to the course in this part. I want to start coding the loading functionality. Basically, we're gonna load it or reticence with the basic function already, but we need to split apart or the string para meters and fill them back into our interface , and that's more going to be some bits. Code heavy, I would say. But we hopefully can do some, like, copy and pasting around for some specific items for self going. Open up your game manager and maybe gonna go to the very bottom or wherever your police and like well, we know want to do. Is we'll, of course, need to create a function where we are actually going into the load the game part. So we say Boyd, load the game open, close brand to seize. We don't need to do this public or anything, except do you want to have loading and saving on ah buttons. But I don't recommend doing load on the button, except you're going to restart the scene, and that's probably the easier way to do it from a button. What we want to do that first we want to check if we have an actual safe file. So we want to check s if plant crafts and don't has key. So do we have a key already? Which is Cold Idol safe. Make sure that naming convention is correct. Like however we have safety it here in this string, you always need to have a tear. And also here that's important. Just make sure you copy paste correctly or put it in has a test to beat. Now what we do is we gonna catch the data from the limb from the load function. So we say we create a new string. We call it data. Since we need excess to this in a second. When I want to do is we want to go to say Flowed script and we want to loot. And as you can see, that just gives us bank a data strength. So this does now call this function saves that from the given given key and returns his bank to whoever was requesting this in this case, the game manager. So now we have all the data and here and the string. Now we need to split the data since we have no numbers and pipes in between as a separator . We need to make sure that we separate them. So at first we're gonna put all of that in a string, right? I gonna call it may be a string list, and we're gonna set this one equal to now. We want to take or talk to data, and now we want to split the requested data in here. In between those Prentice's we gonna have to put in our character which cut is our separator and the number. So at first we're gonna put in, quotes our pipe, and then we leave a space, and then we're gonna put in square brackets and put in a zero. And, of course, we enter line was a semicolon. So this way we're gonna split the data with this operator, where or with this pipe into on one string away or actually, in this particular strings and passes over into the string list direct. So now what we need to do is we're gonna loop through the complete string list and put the data back into our game manager so into all our any drink list or into the drink list and fill in all the drink amounts back into this That's what bloating is doing for us. So we grade the new four. Look, once again we type and four tap twice. So we gonna have the possibility to create the fall of automatically tep another one And then we're gonna put in the string list. Don't lengths, lengths. In this case, censoring is off type array. We're gonna need to take links. And since there's also money inside the string nous, we need to negate this Buy one, because money is going to take be taken later on. Separate Lee from the last year item in the string list. That's what we need when we need to say here minus one, Absolutely important. Don't forget that we create a new, temporary Inter Joe over here Pull loop. And what we want to do is we want to pars the string back into an integer so we say and don't pars like so and now we need to say, with string, Do we want to actually pars back into an inter job? It's going to be string list in square brackets. I So the currently looked through item and of course, we close the line was a semi column now temp holds the current data off the amount we currently have in. Now what we need to do us, we need to fill the data back into the drink list. So we say drink list in square brackets. I don't drink. Amount is equal to temp. So, temp, once again, it's the paused indigent over here. That's what we need to do. Otherwise, we're not able to bring back the data inside our game. Now what we want to check is if our item amount like temp is bigger than zero and effort is so we want toe unlock the next item because this unlock ability is not going to do it automatically. Whenever we feel in the data, we need to set this by hand, basically or in this case, per reiteration. So we say if TEM is bigger than zero, then we want to have another request. That means we need to check if I plus one is smaller than the drink list that count. So I say, if I plus one, we need to do this because we otherwise would have an overflow later on, or an argument out of range. Exception dot count So meaning we only unlock seven instead of eight. Because once again, we have seven insurgents. But I is probably going higher than that. And we don't want to have an unlocked Let's sail number nine because there's nothing inside that that will protect the overflow. So that is the case we're gonna put in drink list. Inscribe rickets, I plus one. So we actually we unlock the next item. If the last item is set correctly, like if it has more than one, we know that the next one needs to be unlocked. Otherwise, we are unable to fill the list correctly. So we set this one to be true, and the next port would be We need to fill the list, fill the list. The point is, we are unable to fill the list over here directly because it would give us some problems. So we need to create our own fill this tongue Tonality for that when we are done by when we're done was looping through all this items just to finalize that last step. We're gonna say money is equal to float. Now we need to pass or pars a float back from our split string. We're gonna say we want to have the float from string list in square brackets, number eight. So whatever is on number eight should be our float. And this returns the correct money amount. Great. When we also want to do is we want to I'm gonna leave a space over here. We want to update our money. You? Why? Up close? Prentice's closed the line was a semi colon, and we want to calculate our GPS because this needs to be recalculated and re visualized for us in the next part, we're gonna fill in more necessary information. 34. #34 Loading The Data 2: Welcome back to the course in this part. We want to continue our loading part. First off, I want to go to the game manager and want to tank. How we want to actually fill the current data inside we need to do is we need to create a little F statement in here and check how we want to say for how we want to load the game for us off. In this case, only loading appears. What we want to check is if our player probes do have a key and the key once again is going to be our idol safe. Make sure you have no typos. So idle safe once again, that needs to be the same key as recreated over here. If you are unsure, just copy and paste, Dad. And if that is so, meaning we gonna go and loot the game. So we call load the game function over here. If we don't have the key, we're gonna need to put in an else statement over here else. We want to just call Phil list because nothing is another safe game, actually. So every time we gonna start now, I contest this one owned I can put in the money. The last time I saved, I guess it was like 22 also in the consul. You should see a change like game has been loaded. Let's try that out. As you can see, the game has been loaded and the money is 22 s safe before. Also, it over saved the same just in case, because that's happening. Do it through out of state. What you also can see is even if I un pause, we cannot see the content in the field is because in load, we don't do feel list. We're gonna go over that in just a second. So what we no need to do is we basically need to fill the list also whenever we're loading the game, right? So first off, we need to know all the data, the necessary data, an update, everything accordingly. What we can do is you can copy for a list, go down no place safe and do the field list that stuff over here. But I go to going to show you what's going on with that when we know press play. Since we have a say state or I have one. It's going to load correctly, right? If I now do protests or maybe two, maybe three. You're gonna change something over here. We're gonna have some differences laid on what I need to wait. Four is on. I need to know at a specific point that this has been saved again. Gonna clear the consul. So I see stuff better. And whenever it has been saved, there's going to be a floor. I'm gonna have to wait until this is going to happen, so I'm gonna get myself some money over a year. Doesn't really matter at all because this is going to be saved. Completely correct already. Maybe I'm gonna buy another one over here to make it more visible. And now wait until the next safe is going to come over here. Should be happening in the next 10 to 15 seconds. There we go. So it has been safe. Now we know that we have saved. But now let's second what's going to happen when we're filling the list with the current safe data? What you can't see it is not filling up correctly. Also, it shows us Oh, we have a coast of 1000 So what does it mean is even if these are unlocked here already? Correct? We don't fill the correct item holder into the list, and that's a problem, since we off cause. Want to make sure that everything works correct? Well, we can do with that. Is we asked to create a new Phil object or fill list item? Hold a creation based on if something has been unlocked or not, because otherwise it's getting ignored. Do it through our fill this functionality, as you can see. Of course, here we're gonna check if something has been unlocked, but also we actually disabled on functionality by the drink list amount. Or if something has been instance, we cannot get away from that because it doesn't make sense. So this basically this field list items info is only working whenever we have lower than zero are actually zero drink amount or have not been instance or ready. So that's what we need to take care off. And that's what we're going to do in the next video 35. #35 Loading The Data 3: welcome back to the course in this part. We want to finish up the loading process. So all the necessary data and all the necessary item holders are correctly instance, too. For instance, she ate it. We're gonna need to do is we need to check every single item which we had actually looping through in this four loop and see what's going on with them to do. So we're gonna create a new function, and I can call this maybe, Phil. Single item of a here when we need to pass in is an indigent off the idea we're currently looking through. So each interational through the four each gives us a number. I we're gonna put an I as an indicator for the currently looked through I d and call Phil single idm. So this is going to happen over here and off course. We put in I in this Prentice's so this called that? Okay, Now what we need to do is we need to check, of course, the same way as we have done in the eye or in the drink list. First off, we need to make sure if this one is on. Not so you can basically go to the field list and copy and paste some lines of code back in force. So I'm gonna take this and put this over here. So if drink list, I is going to be unlocked. But since I is unknown, we need to change this one to I d because that's the i d. We're gonna pass in if you want to keep I As is no problem, you can do it the same way. So this once again is going to be the Iight in the I. D. Into this. We can also put all the complete stuff into the swore loop. But it would be too crowded, and that's why I take it into an extra function. What we're basically gonna do now is we're gonna create an item holder so we can't basically copy all of that from the drink list or feel list over here. Those two lines and I got a copy and paste them over here. So if the item which we're currently talking to has been unlocked, we create a new item holder and, of course, talk to the item holder component and catch that well, we now need to check is if the drink amount is higher than zero. We already have done the same as well over here. They're gonna copy this and bring this down below. And of course, I can close the statement already. What would basically do is the same stuff in the field list. So basically, we can also go and copy the complete function over here, and we can also put or that part into it. So what do you know? Do is you just simply copy from the field, list this complete functionality and put this into here? Of course, you need to get rid off the other s statement because otherwise it doesn't make sense. So what we now do is we update each single item without a four loop just by talking it to it from the load game functionality over here. Once again, we can only do this. Where do through that. Because otherwise we cannot update it accordingly over here. So let me get rid off this field list over here because I want to show you something. Don't forget to save everything. If you have done any major changes. Same for the script. And now let's load of a game. What you can now see is we only update unlocked items. As you can see, the water we have purchased for our money is correct. Total G. P. S is correct as well as we got one lemon juice before. But as you can see, the next item over here is not unlock. I mean it is, but it's not visible. And this is only possible to do, as you probably see now is whenever we have nothing or whenever we have something like with being unlocked but not being over drink, amount of zero or being instance, What we can do now is we can basically once again keep the field list. Functionality are online over here again. So after all, the already unlocked once have been unlocked correctly and filled correctly, we're gonna use feel list toe unlock the last one. Don't forget to save the script and let's take it out. S signal can see the next item would be 1000 and coast. So we can literally go into this, of course, purchase it by giving ourselves some money and press by. And now we unlock the next one. And whenever once again. The same game is saving again. The next one will be also I'm not. It will be automatically after, although safe is done, completely correct will be stored inside. I will play a pref in that long string and later on, whenever we load back to it, we're going to get everything back as we have done before. And so this way we can load razor. Let's a complicated, but we can safe. There is a simple This is absolutely necessary because on the other hand, there would be even with the buying a reform hitting or wizard XML file, you need to pass back the data correctly. Once again, you can see now the game has been Safed. When I play again, the older loader should work and also unlock strawberry juice automatically. Now you can play the game, the wool time and you every time it's going to save like every once a minute, you gonna be able to purchase something, the money will be stored. The G P s is automatically calculated as you probably remember, and so on and so forth. So we don't have to take care off anything because all the complete systems are running on their own 36. #36 Formating Numbers: welcome back to the course in this part. I want to do some clean up or actually, some adults to our money. Visibility. I'm gonna show you what I mean. First off, all big numbers and I was an e plus zero seven. Also, when you go down and you have purchased some of thes, you're going to see that they are going to actually need some quite high numbers, or we can do is you can do the same as we have done to the total money toe all our items to show them and update them correctly. The only thing is, these numbers will not be round correctly at a specific or from a specific point on, However we can visualize it. So that is looking like I say better than just was. This is numbers What we did, Teoh the update money user interface or you I function. We added money dot to string into. Basically, what we can do is everywhere where we're gonna spend money where we update money and anything else we can copy and paste that onto it. So, everywhere where we talk about money or even GPS, so what? We get dues for example, all GPS. We can add the two string or don't to string and to hear as well like this. And we get to the same wherever we like to wherever it comes. Teoh, you know, repeating or Ansley updating taxed with a specific string. In this case, whatever the mountains are. When we go further down, we can see in the fill single list item. We're gonna have the same over here for a MT. GPS and coast, Same for the other three down below. Well, we're gonna do is we're gonna take the drink amount over here. And since it's going to be still a straight number like an even number no comma science, we still want to make sure that we don't overdo it at this point. So we can do is you can basically take all of these and give it the extra dot to string and to same down below. Over here don't to string. And to this is once again a design decision. You can take over or at the moment, so end to in this case is in americ function or in America, one which has a two comma science after the last point. We can also do the same in the very top where we're buying the items, since we do update them here as well. So we're gonna put this over here, the DPS in the coast and even further there are more than that. It's going to be in our field list function where we're going to do the same to times. So at first over here, where we are actually creating the first ones in Same here. If we're going Teoh, do the unlikable ones. Don't forget to say the script. Once you're done, make sure you have done all of them or all of those you like to use over here. And let's return to unity and check it out. The best way is you give yourself a good amount of money like some couple off millions. Probably 200 million or whatever and test out if everything works and go purchase some of your items. What you're gonna see beforehand. This water was like an e number. Same for the lowest one of either 20 million coast of there wasn't any number as well. So this way we can avoid or Ashley updated so that we can see big numbers. Same for the total GPS. Same for the total money. Same for the amounts. As you can see, amounts do have now the 0.0 over here as well. So you probably want Teoh change those about the amount a bit different in this case, if gannet gonna be an zero. So what we're gonna have is zero comma signs or zero numbers behind that because we only have straight numbers, so go down and everywhere where it say's amount put in and zero. Don't forget to say this group once again the game and it just gripped and press pride again. What he now I can see is the mountains rounded down a to a full number again. Or actually visualized to that, or for us to be straight or like an integer number without any digits behind the commerce on s the GPS over here as well. If you don't want that, the change for the GPS, you're absolutely free to do so. But the higher the numbers are going to be the total GPS wolf, sooner or later, it a quite high number as well. So you're gonna have fixed that as well 37. #37 Rearrange Editor Scripts: welcome back to the course in this part. I want to show you something, which I forgot to mention when we were creating Aditya script. What we can gonna do usually is when we are creating editor scripts like this Asset Prevue . This needs to be in a specific folder. It doesn't matter where the folder is, but probably a bona put this into the streets full as a sub folder. And this folder needs to be called editor. So usually everything about editor scripts or which is used in added the script should be in the editor fold over here, make sure you take as a preview and direct us into editor. What's going to happen is that the compiler runs once and when it is done was that all of the editor scripts works as it's supposed to be. Just keep that in mind so you don't mess around later on. Was the editor or probably you use another version off Unity, which probably does not support editor script this way. I showed you before 38. #38 Game Saved Indicator 1: Welcome back to the course in this part. I want to create some small let's say, blinking text indicator, which is going to tell all players that this game has been Safed first and easiest one is going to be. We're going to go into a canvas and created new text. So go to you. I text we can do. Is that of course, the first rename it I'm gonna name it may be game Safed, text weaken. Basically, put this wherever we like in police. We're gonna make it probably best fit. And of course, we go to duty to d mode over here if we haven't already and makes so that it probably pops up in the bottom, right. You can also center this one whatever you please. And like once again, depending on the size and so on. Also, what I want to do is I want to put in the text directly in here because we don't have to update this one later on. So we're gonna put in something like Game Safed as a taxed once again. You can and do it whatever you like or however you like. I gotta make it maybe read or a super darkish blank and maybe bold. So it's noticeable. And I'm gonna place this one probably in the bottom right corner, and maybe are gonna anchor this to the top and bottom right as well, by holding down the old key and set the anchor to the top. Or, in this case, bottom right. Gonna drag it away a bit from there, so it totally states at this position. Next. What I want to do is I want to go to window animation animation, and I want to create a new animation clip. In this case, I go to my assets, animations, holdem And where what? We're gonna have us Those other animations already in here I'm gonna name it may be blinking or blinking. Safed. I'm gonna say that and now I can animate this. So what I want to do is they want to let this maybe blink two times, like reducing an increasing elf over time. And then it's gonna disappear based on the animation lengths. We're going to do this, for example. We can put it into one second or we can even take more time for that. But I'm not quite sure about this First off, I want to go into the text part of a here at a property off type color, since color has no just rtb but also Alfa. As you can see at the very bottom, we're gonna make use of that. First off, I want to make sure that their removal the other properties, which probably is a bit hard to hit except Alfa in this case, one What I want to do is I want to create an Alfa key over there in the center. So it's blinking at least once, meaning it starts at the very first over here as one elbow. You can also check this down below in the window off the game itself. Then, as you can see, it reduces Alfa 20 And then it actually reactivates it again. Or I can do is we can also change these keys, for example, with select them with the mouse and direct them all over. So in this case, we're gonna start with L for zero. Then we're going to bring it up to one at the second of 0 15 in this case, 15 Middle East seconds. Now you can put them the other one to the 30. We can also copy keys or copy frames in this case, over here. I want to reduce it to zero, but not at the frame where I am, but the one where it's contains. Actually, it asserts key frame. So what we're gonna do have now is a zero and one and a zero again. Now we go to the time limit 0 45 increase it to one again and go toe one second and reduce it to zero again. So when we play that on this little prevue over here, you can see it is quite fast. A blinking two times when we can do is we can stop. That was a rule, or was a mouse wheel. We can go down a bit and select a mall and take this little Marco over here so we can stretch this accordingly to be like a two second animation. And there we go. So once that is done, we're good to go for doing. All the rest was to code. So we just activate this game text or game safe text whenever we need that. Also, what you want to do is you want to go to the animations for the first blinking saved, which is not available. So deactivate loop, herbal or loop time over here. 39. #39 Game Saved Indicator 2: welcome back to the course in this part. I want to make sure that we activating and deactivating the game safe, taxed whenever the game saves the easiest one to do this is doing the Deac division directly on the text. So we're gonna need to create a new script for this. So I'm gonna create a new C shop script and I call this deactivate text in this deactivate tax function or script, we don't do basically the same as we do in the pope Up tax directly on start. First off, we want to know what is Don't going to be the length of the animation off our text, and then we destroy it. So basically, what we can do is we take this particular part in the start method. So what I do is a copy the 1st 3 lines over here and go to this one. What? I want to make sure that I get the animator component at first. So the best way over here might be putting the class already or the animator component over here into this and get its component residents start when we don't want to do is we don't want to get it from a Children. So we just say get component, Animator, Since this is not sitting on any Children over here, next one is we don't want to destroy the game object after a given amount of time, I want to make sure that we deactivated after a given amount of time Or we can do Here is basically we sent this particular game object deactivated. After this time in this case, we create a new function deactivate. And once we're calling this, we can say this start, game, object or just game object Don't sad active, and then an open close parentheses. We're gonna put in a false we know want to do is want to invoke deactivate by the infinite clip lengths. In this case, we're gonna get rid of that and start to create the invoke message first in this case, invoke then in quotes we're gonna need to call deactivate as we have time before, several times and we said comma. And then here comes to time. The time in this case is going to be this one. So info in scrap bracket zero dot ca lib dot links We get rid of destroyed since we don't need this. And of course, we close the line. Was the semicolon over here? So And start whenever this gets activated, we gonna deactivate it after a given amount of time. What does it mean is in game engine? We need to make sure that we deactivate this particular game. Object one start. So how can we do this? Of course. We need to make sure that in start, we already know what this game object is about. Or in this particular case, at first Anyhow, the game object. So I got a name it saving or give it the command saving over here and when we need to do is we need to have a connection to the game. Object first. In this case, it's Owen safe text. Now, what we want to do is in start, we want to deactivate safe text. So safe text don't set active and open close parentheses to be false. Don't forget to save also go to back to the game and so the deactivate tanks script and make sure you have safe this one as well. So now what we need to do is we need to activate this particular script from the game manager whenever we're starting. So we go down to our order safe. And whenever we're done with saving the game we call safe, Thanks don't set active and open close parentheses to be true. Now, usually it should happen that we are saving and activating the tent, this text component or, in this case, this game object to do our animation. Over here we get the animator component of their Whenever we're starting this and we should play the animation on once animation is done, we're gonna deactivate the called game object once again, don't forget to save everything and see if we're gonna have any problems in the compiler. Now, since we're done with that, we need to make sure that we put a deactivate taxed asked component on to our game Safe text. Let's try that out. One game gets saved and now the game object should be deactivated. As you can see over here now, whenever we're waiting for another minute, I can also go and clear the consul to see the debug line coming over there as well. Or deactivate. Maximize on play works the same way you got to make sure that a consul showing up correctly , our game saved and our animation is going to start again. Now you can see the game of Jenga gets activated over here. The deeper Klein say's that the game is saved. Also, you can see game safety over there. And now we have a problem that this is not going to deactivate itself again because start only gets runned. Once we need to do is we need to change the start message, Toby. Another message over here in that case needs to be called on unable. Don't forget to save. And let's test this one out once again. So we gonna save our game at the very beginning. Once again at the game, object gets deactivated the first time we can clear the consul And wait another minute until the file is completely correctly running. Now you can see game safety has been started. It was blinking, and now it gets deactivated once again. So the faction on enabled is only called or every time called this function, or this script gets earn abled. Just keep that function in mind because probably another project. You might want to make use of this once again 40. #40 Clean Up: Welcome back to the course in this part. I want to do some clean up. First off, when I start my game, I'm going to see that All my Yeah, units over here, all my images are not going to be in the center off. My graphic also saying, for the the question mark images, What we can do is we can go into a scroll, regret and put in pretty quick one of our prefab off the item holder. You probably have done this so far on as you can see, when I assume in that this one this image is going to be a bit shrink down. What? I want to make sure that this item image basically estates at the same size as the other container over here. So Well, that can basically do Is I just drag it all over over there might be squeezed later on on my graphic. But what I can do is when I have a sprite on this this I can say I want to preserve the aspect ratio. I don't want to make sure that I d activators or actually put nothing inside anymore. When an owl press playing of course beforehand applied the changes to the prefab. I want to get rid off item holder and play again. So now all my graphics, as you can see, are in the current sponte preserving aspect ratio. You can check this by clicking on the item holder item image, and you can see preserve aspect. Make sure that they're staying at this. Yeah, the graphics they should be. And that's a good thing because otherwise it would be squeezed just because I was, you know, dragging around all this content. So if you want to clean up even more, you can get rid off all debug lines we have here. In this case, it's just game loaded and game. Safed. Everything else which you don't need should also probably be in your cleanup section. So meaning do not stay was too much off these d buck lines over there. So you can probably get into this. And wherever you have put in any deep appliance in total, you might want to get into that and get rid of them. The most easiest way is of course, using the search function over there so we can search well debunked a log and everywhere we have some debunked long. Like, for example, we don't have enough money, game safe and game loaded. We can get rid of thes de Brookline's. If you want to do something for the not enough money part over here, you can even put in a blinking taxed as we have done. Where's the game? Safe, taxed and put this into the center off the playfield or whether you like him, please. So to finalize the cleaning up, get rid off all debug clients you can find, Don't forget to update the scripts. Whenever you do stuff, I'm gonna go in here into the same script and get rid of all my other deeper clients over there as well. Once again, don't forget to save and you're done was all clean up. Don't forget to apply the changes. If there are any as well as safe, your project 41. #41 Conclusion: Welcome back to the course. This is going to be the conclusion Video off this course. Now we're gonna pretty quickly recap what we have done so far. First off, we designed a complete interface by using different graphics and buttons just to make sure we gonna put all these in tow item holders, we created the scroll Herbal content list. We give everything some prize amount of GPS and also all the money and stuff like that in the top. Over there, we made sure that we have a collectible container which is animating itself. So you created animations on your own. You were able to create script herbal objects, with also some editor scripting onto this to make it more visible and make it more, Let's say useful for us. And also you learned about game and adjust itself. You're gonna learned how to set all stuff up. You learned about Yeah. Lists very Abel's money and total and so on. And so force. So, as a conclusion, you should have, like, this complete project, as is, as we created this one together. And probably there's going to become a part two later on, or we go over achievements, and probably also upgrading the drink amount list or the drink amount by when we're creaking this container. But if you want to do yourself a challenge, you can do that for yourself. It's well meaning. How would you implement a upgrade system for the clicks? Just think about that. And, of course, make sure you make use of it if you like to. Of course, once again, Same for achievements. What do you think good achievements do and how do they react to that? And how could you count the correct numbers up or down to whatever? And how would you showcase that? Somebody achieved something. Thanks a lot for tuning in and taking the scores. I hope you enjoyed this one and hope to see you in one of my other courses as well.