官术网_书友最值得收藏!

Chapter 4. Getting into the Details of Methods

In the previous chapter, you were introduced to a variable's scope—where a variable exists and is allowed to be used. The scope is determined by the "opening" and "closing" curly braces. The purpose of those curly braces is to act as a container for a block of executable code, a code block. In second chapter you saw that a method is a code block that can execute by just calling the method's name. It's time to see the importance of code blocks and the variables used in them. A method defines a code block which begins and ends with curly braces.

In this chapter we will cover the features of methods:

  • Ending method definitions with curly braces
  • Using methods in a script
  • Naming methods properly
  • Defining a method
  • Calling a method
  • Returning a value from a method
  • Using Unity's Update() and Start() methods

Variables are the first major building block of C#, methods are the second, so let's dive into methods.

主站蜘蛛池模板: 乌兰察布市| 体育| 日照市| 桦甸市| 盖州市| 霍城县| 南江县| 灵川县| 葵青区| 云龙县| 安陆市| 张北县| 马山县| 三门县| 阿克| 鹰潭市| 马公市| 五大连池市| 华亭县| 靖安县| 贡嘎县| 靖宇县| 邵阳县| 都匀市| 苗栗县| 耿马| 沙田区| 武安市| 磐石市| 木兰县| 招远市| 永嘉县| 金寨县| 扬州市| 杭锦旗| 鄂托克前旗| 阜南县| 舒城县| 河北区| 灌阳县| 合肥市|