728x90
AddLisener ๋ก ๋ฒํผ์ ์ด๋ฒคํธ ํ ๋นํ๊ธฐ
1. ์ธ์๊ฐ ์๋ ๋ฉ์๋ ์ผ ๋
void Awake()
{
button.onClick.AddListener(PressBtn);
}
void PressBtn()
{
}
2. ์ธ์ ์๋ ๋ฉ์๋ ์ผ ๋
void Awake()
{
button.onClick.AddListener(() => OpenPopup("Title"));
button.onClick.AddListener(delegate { OpenPopup("Title"); });
}
void OpenPopup(string title)
{
}
์ธ์๊ฐ ์๋ ๋ฉ์๋๋ฅผ ํธ์ถํ ๋๋ ๋๋ค์์ด๋ ๋ธ๋ฆฌ๊ฒ์ดํธ๋ฅผ ์ฌ์ฉํ๋ค.
* ์ฐธ๊ณ
https://docs.unity3d.com/2018.3/Documentation/ScriptReference/UI.Button-onClick.html
728x90
'๐ฎ Unity Study > Unity' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Unity] Sound ๋ชจ๋ฐ์ผ ์ต์ ํ (0) | 2024.04.30 |
---|---|
Unity Canvas :: Reference Pixels Per Unit (0) | 2024.04.16 |
[Unity][MenuItem hotkey(shortkey)] %(ctrl, cmd), #(shift), &(alt)... (0) | 2024.01.24 |
[Unity] Github package npm ๋ฐฐํฌ (0) | 2023.12.07 |
Android API version ๋ณ SDK ๋ฒ์ (feat. Unity ๋ฒ์ ๋ณ NDK, JDK Version) (0) | 2023.11.29 |