2018.4.2f1 버전으로 개발 중 Standalone 버전 개발 중에 클라이언트에 포커스가 가 있지 않으면 버튼의 Hover 이벤트는 작동하지 않는데 마우스 포인터 이벤트는 작동하는 이슈가 발생했습니다. 여기서 더 이슈가 되는 것은 5.3.8p2 버전으로 개발한 다른 클라이언트와 다르게 작동한다는 것이었습니다. 해당 부분은 비슷한 스크립트를 사용하였기에 버전 이슈겠지만 좀 더 정확한 확인을 위해 분석을 해보고 기록을 남깁니다.
마우스 포인터는 Raycast를 이용해 구현했었고 버튼은 UGUI의 Button을 사용하고 있었습니다. 기존 기능들에서 문제로 예상되는 부분들을 모은 스크립트를 생성했습니다.
| using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class FSelectable : MonoBehaviour, IPointerEnterHandler, IPointerClickHandler, IPointerExitHandler { private List _raycastResults = new List(); private int _prevRaycastResultCount = 0; public void OnPointerClick(PointerEventData eventData) { Debug.Log("OnPointerClick"); } public void OnPointerEnter(PointerEventData eventData) { Debug.Log("OnPointerEnter"); } public void OnPointerExit(PointerEventData eventData) { Debug.Log("OnPointerExit"); } public void OnApplicationFocus(bool focus) { if (focus == true) { Debug.Log("isFocused"); } else { Debug.Log("isFocusOut"); } } public void Update() { if (EventSystem.current == null) return; PointerEventData eventData = new PointerEventData(EventSystem.current); if (eventData == null) return; eventData.position = Input.mousePosition; EventSystem.current.RaycastAll(eventData, _raycastResults); if (_prevRaycastResultCount != _raycastResults.Count) { _prevRaycastResultCount = _raycastResults.Count; if (_raycastResults.Count > 0) { Debug.Log(string.Format("Raycast hit {0}", _raycastResults[0].gameObject.name)); } else { Debug.Log("Raycast hit nothing"); } } } } |
테스트는 Editor Mode, Standalone Mode 에서 실행하였고 Standalone Mode 에서는 Run In Background 옵션을 포함한 버전과 포함하지 않은 버전으로 구분해 테스트 하였습니다.

테스트 결과는 아래 스크린 샷과 같습니다.






|
with Run In Background |
without Run In Background |
|||
| 5.3.8p2 | Focus | EvenSystems Interface | O | O |
| Raycast | O | O | ||
| OutFocus | EvenSystems Interface | X | O | |
| Raycast | X | O | ||
| 2018.4.2f1 | Focus | EvenSystems Interface | O | O |
| Raycast | O | O | ||
| OutFocus | EvenSystems Interface | X | X | |
| Raycast | O | X |
구글링으로 비슷한 케이스를 찾지 못해 커뮤니티에 글을 남겨봅니다.
2018.4.f1 Standalone client application button not working properly when out of focus - Unity Answers
answers.unity.com
'Works > Unity 3D' 카테고리의 다른 글
| [Unity3D] CS1617: Invalid option 'latest' for /langversion; must be ISO-1, ISO-2, Default or an integer in range 1 to 6. (0) | 2019.09.10 |
|---|---|
| [Unity3D] Memory Profiler 설치 (0) | 2019.08.29 |
| [Unity3D] Google Play Console 빌드 업로드 에러 (1) | 2019.08.21 |
| [Unity3D] Admob Proguard Issue (1) | 2019.08.19 |
| [Unity 3D] 안드로이드 64bit 대응 (0) | 2019.08.05 |
댓글