-
[TIL] 15주차 1일 오류 개선 사항개발일지/스파르타 코딩클럽 유니티 강의 2024. 7. 22. 21:16
트러블슈팅
달리다가 메인메뉴를 켰다가 끄면 첫 번째 인풋이 먹히는 문제
원래는 많은 부분에서 UI를 키면 IdleState로 돌려주는 등의 강제로 State변환을 했었는데
그런 방식이 버그를 많이 발생 시키는 거 같아서
public void ToggleUI<T>(ref T ui, float uiOnTimeScale = 1f, float uiOffTimeScale = 1f, bool isESC = false, bool isCheckpoint = false, int mainMenuIndex = 0) where T : UIBase { if (ui == null) { //onUI = true; SetOnUI(true); player.Input.PlayerActions.Disable(); ui = Show<T>(); ui.gameObject.SetActive(false); } if (activeUI != null && activeUI != ui) { if (isESC) { activeUI.OffUI(); //onUI = false; SetOnUI(false); player.Input.PlayerActions.Enable(); activeUI = null; Time.timeScale = 1f; return; } if (isCheckpoint) { activeUI.OffUI(); //onUI = false; SetOnUI(false); player.Input.PlayerActions.Enable(); activeUI = null; Time.timeScale = 1f; } } if (ui is MainMenuUI mainMenuUI) { if (activeUI != ui && onUI) { return; } if (activeUI == ui) { if (mainMenuIndex != mainMenuUI.currentTapIndex) { mainMenuUI.SwapMainMenu(mainMenuIndex); return; } } else { mainMenuUI.SwapMainMenu(mainMenuIndex); } } if (ui.gameObject.activeSelf) { Time.timeScale = uiOffTimeScale; ui.OffUI(); //onUI = false; SetOnUI(false); player.Input.PlayerActions.Enable(); activeUI = null; } else { Time.timeScale = uiOnTimeScale; ui.OnUI(); //onUI = true; SetOnUI(true); player.Input.PlayerActions.Disable(); activeUI = ui; } }
UIManager에서 모든 UI를 관리하는데 UI가 켜지면 PlayerAction Input을 Disable 함으로써 해결했다.
체크포인트 연출
앉아서 쉬는 애니메이션을 만들어주고
스테이트 머신에서 해당 스테이트를 만들어준 후
private void OnEnable() { stateMachine = GameManager.Instance.Player.stateMachine; player = GameManager.Instance.Player; firstBtn.Select(); if (CinemachineVirtualCamera != null) { CinemachineVirtualCamera.Priority = 20; stateMachine.ChangeState(stateMachine.RestState); } else { CinemachineVirtualCamera = GameManager.Instance.Player.GetComponentInChildren<CinemachineVirtualCamera>(); CinemachineVirtualCamera.Priority = 20; stateMachine.ChangeState(stateMachine.RestState); } }
체크포인트가 켜질때마다 해당 스테이트로 이동하고 카메라가 줌인되게 연출했다.
( 애니메이터 트랜지션때문에 골치아팠다.. )
다른 UI켜졌을 때 체크포인트 인터렉트 되는 부분
이 문제는 위의 PlayerAction을 막으면서 Player의 Interact도 자연스럽게 막혀서 해결되었다.
UI 관련 인풋 문제
이 문제는 강제로 스테이트를 Idle로 변경해주는 과정에서 뭔가 충돌이 일어나고
버그가 발생하는 거 같았다.
첫 번째 문제의 해결로 같이 해결되었다.
'개발일지 > 스파르타 코딩클럽 유니티 강의' 카테고리의 다른 글
14일차 카드 배치하기 ( for 반복문 ) (0) 2024.04.08 13일차 르탄이 카드 뒤집기 게임 (0) 2024.04.05 12일차 레벨 구성하기 (1) 2024.04.03 11일차 고양이 나타내기 (0) 2024.04.02 10일차 고양이 밥주기 게임 (0) 2024.04.01