ํ๋ ์ด์ด Action ButtonPress
์ธ๋ถ ํด๋์ค other
other์ย Action func
์ธํ ๋งค๋์ InputManager.instance.Action InputPress
์ด ์์๋,
On() ์คํํ๋ฉด,
1. other ํด๋์ค์์ย Player.ButtonPress += other.func
2. InputPress += ButtonPress
Off() ์คํํ๋ฉด,
1. other ํด๋์ค์์ย (Player.ButtonPress -= other.func)
2. InputPress -= ButtonPress
์ด๋ ๊ฒ ํ์ ๋, Off๊ฐ ์คํ ๋์๋ค ํ๋๋ผ๋ ButtonPress๊ฐ ์๊พธ ๋๋ฆฌ๋ ํ์์ด ์์.
๋์ ์
Off() ์คํํ๋ฉด,
1.ย InputPress -= ButtonPress
2. other ํด๋์ค์์ย (Player.ButtonPress -= other.func)
ํ๋ฉด,
์ ์์ ์ผ๋ก ButtonPress๊ฐ ๋ ์ด์ ๋๋ ค์ง์ง ์๋๋ค.
์ค๋ง.. ButtonPress๊ฐ ๋์ค์ ๋ฐ๋๋ฉด
์ด๋ฏธ InputPress์ ํ ๋น๋ ButtonPress๋ ๋ณ๊ฐ์ Action์ด ๋๋ฒ๋ฆฌ๋๊ฑฐ์?
์ด๋ฏธ InputPress๊ฐ ButtonPress๋ ๋ณ๊ฐ์ ์ก์ ์ธ๋ฐ ์ก์ ์ ๊ทธ๋ฅ ๋ฉ์๋ ์ฃผ์ ์ปจํ ์ด๋๋ฅผ ๋ด๊ณ ์์๋ฟ์ ๋น์ฐํ ๋ค๋ฅธ action์ด์ง ์ ๋ฌธ์ ๋ other ์์ ๋จผ์ ํ์ ์ ๋นผ๋ฒ๋ฆฌ๋ ํ์๋ก ํ์ฌ InputPress๋ค๊ณ ์๋ ์ปจํ ์ด๋์์ ์บก์ณ๊ฐ ๋ง์ง ์์ผ๋๊น InputPress ์ก์ ์์ ButtonPress์ด๊ฑธ ๋บ๋ ค๊ณ ํด๋ ์๋์๊บผ์... ์๋ชจ๋ฅด๊ฒ์ผ๋ฉด ๋๋ฒ๊น ์ ํด๋ด ์คํ ์ถ์ ํ๋ฉด ๋ค๋์ด
C#์์ ๋ธ๋ฆฌ๊ฒ์ดํธ๋ immutable์ +=๋๋ -=์ฐ์ฐ์ ํ๊ณ ๋๋ฉด ๋ค๋ฅธ์ธ์คํด์ค๊ฐ ๋จ.
C#์์ ๋ํ์ ์ผ๋ก string์ด immutable์ immutable์ด๋ผ๋ ํค์๋๋ก ๊ฒ์ํด์ ํ๋ฒ ๊ณต๋ถํด๋ณด๋ฉด ์ดํด๊ฐ ๋ ๊ฑฐ์ผ