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()
{
if (EventSystem.current == null)
if (EventSystem.current == null || MonoUiManager.Instance == null || CurrentSelectionSource == SelectionSource.Direction)
{
return;
}
CurrentSelectionSource = SelectionSource.Direction;
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);
return;
}
var data = new PointerEventData(EventSystem.current);
var currentSelected = EventSystem.current.currentSelectedGameObject;
for (var current = EventSystem.current.currentSelectedGameObject.transform;
current != null;
current = current.parent)
if (currentSelected != null)
{
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);
}