์์ฒญ ์ด๋ ค์ธ์ค์์๋๋ฐ ์๊ฐ๋ณด๋ค ์ฝ๊ฒ ๋๋๋ผ๊ณ
๊ถ๊ธํ๋ฉด ์ฝ๋๋ ๋ฐ๋ฐ
public void OnDrag(PointerEventData eventData){
img.transform.position = Input.mousePosition; //๋๋๊ทธํ๋ ๋์ ์ปค์ ๋ฐ๋ผ๊ฐ๊ฒํ๊ธฐ
}
public void OnEndDrag(PointerEventData eventData)
{
transform.position = startPos; //๋์ผ๋ฉด ํ ์ ์๋ฆฌ๋ก ๊ฐ๊ธฐ
int otherIndex = 0; //๋ฐ๊ฟํ ์ธ๋ฑ์ค
float distance = 1000;
Vector3 mousePos = Input.mousePosition;
for (int i = 0; i < player.slots.Length; i++)
{
float dis = Vector3.Distance(mousePos, player.slots[i].transform.position);
if (dis <= distance) //์ ์ผ ๊ฐ๊น์ด์นธ ์ฐพ์์ ๊ฑฐ๊ธฐ์ธ๋ฑ์ค ๊ฐ์ ธ์ค๊ธฐ
{
distance = dis;
otherIndex = player.slots[i].index;
}
}
player.Swap(index,otherIndex); //์๊ธฐ์ธ๋ฑ์ค๋ ๋ฐ๊ฟ๊ฑฐ ์ธ๋ฑ์ค๋ฅผ ์ธ์๋ก ๋ฐ๊พธ๋ ํจ์ํธ์ถ
}
๊ตณ
๋ฐ๋จํด!
์์ 1% ใทใท
์ถ์ ์๋ฃ
์์ 1ํผ ใทใทใท