![](https://i.imgur.com/IWO9DRT.png) ###### tags: `Unity` | August 17, 2019 # Phase 3 ## 1. States and State Machines (狀態、狀態機) 1. State = Action or Process or Behaviour (物件狀態:可能為動作、行為、過程...) 2. State Machines assumes only 1 state at a time (狀態機一次僅可採用一個狀態) 4. Conditions (requirements) to transition form one state to the next. ![](https://i.imgur.com/Dr25xK3.png) ###### eg: ``` State A Decision State B/C [Start] ➡️ [Room with 2 exits] ➡️ [Which Way?] ➡️ [Blue Door] ➡️ [Real World] ➡️ [Yellow Door] ➡️ [Fantasy land] ``` <!--more--> ## 2. Scriptable Objects (可編譯物件) 1. *ScriptableObject* is a class that lets us store data in stand alone assets. (可以儲存資料於獨立的.asset檔案中) 2. Keep mountains of data out of scripts. (將Data從程式碼中獨立出來) 3. Lightweight and Convenient. (大量資料時方便使用) 4. Can be used as a template for consistency. 5. Don't need to attach to a game object. ![](https://i.imgur.com/4NsiJcW.png) ## 3. Array (陣列) 1. an Array stores into a variable, multiple elements of the same type ##### eg: ``` int[] oddNumbers = {1,3,5,7,9}; Debug.Log(oddnumbers[3]) console result ➡️ 5 ``` ``` string[] daysOfWeek = { "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun" }; Debug.Log(daysOfWeek[3] + "day"); console result ➡️ Thursday ``` ## 4. For Loop (for迴圈) 1. Repeated event until condition is met. 2. useful when counting or iterating ###### eg: ``` for (int i = 0; i < somthing; i++) { //do these things. } ``` ## 3. 名詞講解 ### Sprite 1. Sprite is an 2D graphic object (obtained from a bitmap image) (2D點陣圖物件) 3. Can be **Move, Scale, Rotate... etc**. (可以**移動、縮放、旋轉...等**) ### Components (組件) ![](https://i.imgur.com/RE64u98.png) ### Serialize Field (序列化) 1. Can be put in front of any variables. 2. Make variables avaliable in the inspector. (使變數能在Unity檢視器中使用) ###### eg ``` [SerializeField] Text textComponet; ```