Now it's time to discover the "power" feature of using a method. This usually means sending data to the method, which you just learned to do, then have the method return a value back. Previously, all you had the AddTwoNumbers()
method do was take the result of adding two numbers and display it to Unity's Console.
Now, instead of displaying the result directly, you're going to modify AddTwoNumbers()
to return the result of the addition back to the place the method was called.
The next screenshot is still very simple, but it shows how this substitution works and how returning a value from a method works.
3.147.79.84