๋งˆ์šฐ์Šค ์ขŒํ‘œ์— ๋”ฐ๋ผ

8๋ฐฉํ–ฅ ์ขŒํ‘œ(Left, Left Up, Left Down

Right, Right Up, Right Down

Up

Down)

์ด๋Ÿฐ ์‹์œผ๋กœ ์ถœ๋ ฅํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์žˆ๋Š”๋ฐ

์ผ๋‹จ์€ ์™ผ์ชฝ ๋ฐฉํ–ฅ ๋ถ€๋ถ„์€ ์™„์„ฑํ–ˆ๋Š”๋ฐ

์ค‘๊ฐ„์ด ์—†์ด Left Up, Left Down๋งŒ ์ถœ๋ ฅ๋˜๊ณ  ์žˆ์Œ

์•„๋ž˜๋Š” ์ฝ”๋“œ ์ „๋ฌธ์ž„

using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class MousePos : MonoBehaviour

{

Vector3 screenPosition;


void Update()

{

mousePos();

SetString();

}


void mousePos()

{

if(Input.GetMouseButton(0)) // Down์œผ๋กœ ์•ˆํ•œ ์ด์œ ๋Š” ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ฒดํฌํ•˜๋ ค๊ณ 

{

screenPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

}

}


void SetString() // ํ…Œ์ŠคํŠธ์šฉ

{

if(screenPosition.x < -1 && screenPosition.y == 0)

{

Debug.Log("Left");

}

else if(screenPosition.x < -1 && screenPosition.y < -1)

{

Debug.Log("Left_Down);

}

else if(screenPosition.x < -1 && screenPosition.y > 1)

{

Debug.Log("Left_Up);

}

}

}



1ebec223e0dc2bae61abe9e74683766d1f1765bef60f09562bd39370537a77f448e23b0011ce21ff37721014a9d0f1809e53a695bbf4ef4fcc