diff --git a/BlueWater/Assets/02.Scripts/BlueWater.cs b/BlueWater/Assets/02.Scripts/BlueWater.cs index 6b71f6803..5acffde38 100644 --- a/BlueWater/Assets/02.Scripts/BlueWater.cs +++ b/BlueWater/Assets/02.Scripts/BlueWater.cs @@ -140,6 +140,17 @@ public partial class @BlueWater: IInputActionCollection2, IDisposable ""action"": ""Rotate"", ""isComposite"": false, ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""4bc83c87-5345-4fb2-b39a-ac975f7bf47e"", + ""path"": ""/leftButton"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Rotate"", + ""isComposite"": false, + ""isPartOfComposite"": false } ] } diff --git a/BlueWater/Assets/02.Scripts/BlueWater.inputactions b/BlueWater/Assets/02.Scripts/BlueWater.inputactions index 35cd41580..3a6b7a132 100644 --- a/BlueWater/Assets/02.Scripts/BlueWater.inputactions +++ b/BlueWater/Assets/02.Scripts/BlueWater.inputactions @@ -118,6 +118,17 @@ "action": "Rotate", "isComposite": false, "isPartOfComposite": false + }, + { + "name": "", + "id": "4bc83c87-5345-4fb2-b39a-ac975f7bf47e", + "path": "/leftButton", + "interactions": "", + "processors": "", + "groups": "", + "action": "Rotate", + "isComposite": false, + "isPartOfComposite": false } ] } diff --git a/BlueWater/Assets/02.Scripts/IslandCameraController.cs b/BlueWater/Assets/02.Scripts/IslandCameraController.cs index 87e7af7ec..56d2ec9a9 100644 --- a/BlueWater/Assets/02.Scripts/IslandCameraController.cs +++ b/BlueWater/Assets/02.Scripts/IslandCameraController.cs @@ -80,12 +80,29 @@ namespace BlueWaterProject /// /// New input system을 이용한 줌 인, 아웃 기능 /// - public void OnZoom(InputAction.CallbackContext context) + private void OnZoom(InputAction.CallbackContext context) { + if (!UsableZoom()) return; + var scrollValue = Mouse.current.scroll.ReadValue().normalized.y; desiredZoom = Mathf.Clamp(desiredZoom - scrollValue * zoomSpeed, minZoom, maxZoom); } + /// + /// Zoom 기능을 사용가능한 상태인지 확인하는 기능 + /// + private bool UsableZoom() + { + var mousePos = Input.mousePosition; + // 백그라운드 실행이 아닌, 게임 화면을 실행한 상태인지 체크 + var isFocusedGame = Application.isFocused; + // 화면 내에 마우스가 존재하는지 체크 + var isMouseWithinGameScreen = mousePos.x >= 0 && mousePos.x <= Screen.width && + mousePos.y >= 0 && mousePos.y <= Screen.height; + + return isFocusedGame && isMouseWithinGameScreen; + } + /// /// 자연스러운 줌 인, 아웃 기능 /// @@ -93,7 +110,8 @@ namespace BlueWaterProject { if (Mathf.Approximately(islandCamera.fieldOfView, desiredZoom)) return; - islandCamera.fieldOfView = Mathf.Lerp(islandCamera.fieldOfView, desiredZoom, Time.deltaTime * zoomSpeed); + islandCamera.fieldOfView = Mathf.Lerp(islandCamera.fieldOfView, desiredZoom, + Time.deltaTime * zoomSpeed); if (islandCamera.fieldOfView > desiredZoom) return; @@ -107,11 +125,13 @@ namespace BlueWaterProject if (myPos.y > max) { - transform.position = Vector3.Lerp(transform.position, new Vector3(myPos.x, max, myPos.z), Time.deltaTime * zoomSpeed); + transform.position = Vector3.Lerp(transform.position, new Vector3(myPos.x, max, myPos.z), + Time.deltaTime * zoomSpeed); } else if (myPos.y < min) { - transform.position = Vector3.Lerp(transform.position, new Vector3(myPos.x, min, myPos.z), Time.deltaTime * zoomSpeed); + transform.position = Vector3.Lerp(transform.position, new Vector3(myPos.x, min, myPos.z), + Time.deltaTime * zoomSpeed); } }