Unity has a number of functions which are useful, but we can create and call our own function. As you remember, a function starts with returns type, followed by the name of the function. Let's call it test function and then the parameters. And let's do the same thing which might start function did copy it, paste it here. And one more time. Pay attention to these curly brackets.
We use them if the following code is more than one line, because the function doesn't understand that the second blind is its line also. And so Result works run. Also, you should understand that unity calls its functions for us. For example, the start is called in the very beginning, the update function is called every frame and so on. But who calls my function which I have just created? Well, we have to find a way to call it.
We have to call it from another function that unity calls or from another script. All right, so I'm going to call this function from start function. Meaning my test function is called in the start of my game. test function. All right, okay, let's see whether it works. And yes, here we have the same number because we did the same thing.
But now we received it from our test function, not from the start function. All right, let's, for example, add something like people's D plus plus m plus eight. Okay, we have our a variable here. Save it, so that we have another number. Console. Yeah.
19.6. All right. And we use void type all this time, meaning that a function does not return anything. But let's create a function which returns int variables. I changed my return type from void to end Because the function will return whole numbers and add two parameters divided by coma. So first is why r one, r two of course you should understand that the end is the type of variable and barwon and war two is their names.
All right now let's delete it here. Okay and let us declare our int var three or one or two and ask our function to return it. Return to our tree straight. Now go head to the To start function, I'm going to call test function from here, and then such results involve three and returns it. I'd like to add values for barwon and var two and print the result. To do that, I declare a new variable my var.
Alright, so it's equal to my test function. And let it be, you see, we have like, in part one in order to just the way we have typed it here. So for example, five and three, comma, all right, it should be just the way we want it to be here. We have two parameters here. Both our end so I use int type of variables here I am three. All right.
And now let's print. print this variable. Alright. Save it. Let's go back to our project and check it. All right, go to console.
So here we have eight. I hope you remember that we still have that date function. The our I variable increases every frame. So don't pay attention to that. So we have eight. And that's, that's true.
Five plus three is eight.