# λ²μ
https://www.youtube.com/watch?v=Ic5ux-tpkCE
10 Things You NEED to Be Doing in Unity
## Serializing Component
Update() μμ GetComponent μ¨μ κ°μ Έμ€μ§ λ§κ³
[Serializefield] μ¨μ ν리νΉμμ μ§μ΄λ£κΈ°
## Drawing Gizmo
κΈ°μ¦λͺ¨ μ°λ©΄ μμΉλ³΄κΈ° μ¬μ
## Initialization order
λ³΄ν΅ Awake μμ Instance = this; κ°μ κ±Έλ‘ μ΄κΈ°ν νλλ°
λ€λ₯Έ μ€ν¬λ¦½νΈλ₯Ό Awake μμ λΆλ₯΄μ§ λ§κ³ , κ·Έ λ€μ μ€ν μΈ Start μμ λΆλ₯΄κΈ°
μ΄κΈ°ν λκΈ°μ μ λΆλ₯΄λ©΄ μλ
## Stop using public fields
public int carrotNumber μ°μ§λ§
μλν°μμ μμ ν κ±°λ©΄ [Serializefield] μ°μ
μΈλΆμμ (μ½κΈ° μ μ©μΌλ‘) μ κ·Ό κ°λ₯νκ² νκ³ μΆμΌλ©΄,Β
public int CarrotNumber {get; private set;}
μ리μΌλΌμ΄μ¦ νκ³ μΆμΌλ©΄
[field:Serializefield] public int CarrotNumber {get; private set;}
μ΄ μμ
public Carrot CarrotPrefab => _carrotPrefab;
μλλ κ°μ
public Carrot CarrotPrefab { return _carrotPrefab; }
μΈν° μμΌλκΉ μ½λκ±° λ°μ λͺ»ν¨
## Mod to Loop
int index = 0;
function () {
Β Β abc = array[index++];
Β Β if(index > array.length) index = 0;
}
ν¨μ μ€νλ λλ§λ€ 0 λΆν° λ°°μ΄ λκΉμ§ κ³μ λλ 건λ°
mod μ¨μ ν μ€λ‘ μ€μΌ μ μμ
function () {
Β Β abc = array[index++ % array.length];
}
## PlayClipAtPoint()
μ΄κ±° κ°νΈν¨
(λμλ¦°μ§ λͺ°λ£¨?κ² λ€)
## SetPositionAndRotation
transform.position = ~
transform.rotation = ~Β
λ μ€λ‘ λλ² νμ§λ§κ³
transform.SetPositionAndRotation(~,~);
ν λ²μ νμ . Update μμ μ°λ©΄ μ±λ₯ μͺΌκΈ κ°μ λλ
## Operator overloading
λ 벨 μ μ, μ¬λ¬ μ€ν―λ€μ λνκΈ°λ₯Ό ν λΒ
ν¨μμ κ°λ³ λνκΈ°λ§κ³ μ°μ°μ μ€λ²λ‘λ μ¬μ©
μ΄κ±΄ κ·Έλ₯ μμμ 보μ
https://learn.microsoft.com/ko-kr/dotnet/csharp/language-reference/operators/operator-overloading
μ°μ°μ μ€λ²λ‘λ 곡μ λ¬Έμ
## Composition
μ»΄ν¬λνΈ ν¨ν΄μ΄λκ² μμ΅λλ€~
μμν κ±΄μ§ μ»΄ν¬λνΈ ν¨ν΄ μΈκ±΄μ§Β
## μ½λ© 컨벀μ
https://learn.microsoft.com/ko-kr/dotnet/csharp/fundamentals/coding-style/coding-conventions
c# λ³μ, ν¨μ λ± μ΄λ¦ μ§λ κ·μΉμ΄ μμ΅λλ€~
κ°μ¬ν©λλ€
μ΄ μ±λλ λλ¦ μ μ΅ν μ 보 λͺκ° μμ΄μ ꡬλ ν΄λμκ³³μ΄λ€
mod to loop νμ§λ§λΌ branch νλκ° modλ³΄λ€ μΈλ€