Moa nullchecks

This commit is contained in:
Hubert Mattusch 2023-10-02 21:52:09 +02:00
parent 610179c21d
commit 0148de0db7

View File

@ -55,25 +55,29 @@ namespace NEG.UI.UnityUi
private void SetDirectionInput() private void SetDirectionInput()
{ {
if (EventSystem.current == null) if (EventSystem.current == null || MonoUiManager.Instance == null || CurrentSelectionSource == SelectionSource.Direction)
{ {
return; return;
} }
CurrentSelectionSource = SelectionSource.Direction; CurrentSelectionSource = SelectionSource.Direction;
Cursor.visible = false; Cursor.visible = false;
if (EventSystem.current.currentSelectedGameObject == null) if (EventSystem.current.currentSelectedGameObject == null && MonoUiManager.Instance.CurrentMainWindow != null)
{ {
EventSystem.current.SetSelectedGameObject(((MonoWindow)MonoUiManager.Instance.CurrentMainWindow).DefaultSelectedItem); EventSystem.current.SetSelectedGameObject(((MonoWindow)MonoUiManager.Instance.CurrentMainWindow).DefaultSelectedItem);
return; return;
} }
var data = new PointerEventData(EventSystem.current); var data = new PointerEventData(EventSystem.current);
var currentSelected = EventSystem.current.currentSelectedGameObject; var currentSelected = EventSystem.current.currentSelectedGameObject;
for (var current = EventSystem.current.currentSelectedGameObject.transform; if (currentSelected != null)
current != null;
current = current.parent)
{ {
ExecuteEvents.Execute(current.gameObject, data, ExecuteEvents.pointerExitHandler); for (var current = EventSystem.current.currentSelectedGameObject.transform;
current != null;
current = current.parent)
{
ExecuteEvents.Execute(current.gameObject, data, ExecuteEvents.pointerExitHandler);
}
} }
EventSystem.current.SetSelectedGameObject(currentSelected); EventSystem.current.SetSelectedGameObject(currentSelected);
} }