-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning C# by Developing Games with Unity 3D Beginner's Guide
By :

We're going to modify LearningScript
to send some information to the AddTwoNumbers()
method to make it much more useful.
Why would we need to send information to a method?
A script may need to add two numbers several times, but they probably won't always be the same two numbers. We could possibly have hundreds of different combinations of "two numbers" to add together. This means that we need to let the method know, which two numbers need to be added together at the moment when we call the method.
Using the preceding screenshot, perform the following steps:
Open LearningScript
in MonoDevelop to modify it.
Add lines 6, 7, and 8 to declare three integer variables.
Add lines 22 to 26 to define the AddTwoNumbers()
method with parameters.
Add lines 12, 13, and 14 to call the AddTwoNumbers()
three times.
Save the file.
Click on Play in Unity.
As this script executes, the AddTwoNumbers()
method is called three times on lines 12, 13...
Change the font size
Change margin width
Change background colour