One of the Time for action segments in the previous chapter had you blindly copy a method called AddNumbers into LearningCurve without you knowing what you were getting into. This time, let's purposefully create a method:
- Declare a public method with a void return type called GenerateCharacter().
- Add a simple Debug.Log() that prints out a character name from your favorite game or movie.
- Call GenerateCharacter() inside the Start() method and hit Play:
When the game starts up, Unity automatically calls Start(), which, in turn, calls our GenerateCharacter() method and prints it to the Console window.
If you read enough documentation, you'll see different terminology related to methods. Throughout the rest of this book, when a method is created or declared, I'll refer to this as defining a method. Similarly, I'll refer to running or executing a method as calling that method.
The power of...