# λ²ˆμ—­

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# λ³€μˆ˜, ν•¨μˆ˜ λ“± 이름 μ§“λŠ” κ·œμΉ™μ΄ μžˆμŠ΅λ‹ˆλ‹€~