Event Selection Bug (#404)

The currentEventIndex will no longer change when another UI element is in front of it.
This commit is contained in:
dav 2023-04-27 00:09:43 -03:00 committed by GitHub
parent ac1804a901
commit 6b7e5b67d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 485 additions and 10 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.EventSystems;
using TMPro; using TMPro;
using DG.Tweening; using DG.Tweening;
@ -9,6 +10,7 @@ using Starpelly;
using HeavenStudio.Editor.Track; using HeavenStudio.Editor.Track;
namespace HeavenStudio.Editor namespace HeavenStudio.Editor
{ {
public class GridGameSelector : MonoBehaviour public class GridGameSelector : MonoBehaviour
@ -25,9 +27,9 @@ namespace HeavenStudio.Editor
private RectTransform eventsParent; private RectTransform eventsParent;
[Header("Properties")] [Header("Properties")]
[SerializeField] private int currentEventIndex;
private Minigames.Minigame mg; private Minigames.Minigame mg;
private bool gameOpen; private bool gameOpen;
[SerializeField] private int currentEventIndex;
private int dragTimes; private int dragTimes;
public float posDif; public float posDif;
public int ignoreSelectCount; public int ignoreSelectCount;
@ -48,7 +50,7 @@ namespace HeavenStudio.Editor
private void Update() private void Update()
{ {
if(!(EventParameterManager.instance.active || Conductor.instance.NotStopped())) if (!(EventParameterManager.instance.active || Conductor.instance.NotStopped()) && !IsPointerOverUIElement())
{ {
if (gameOpen) if (gameOpen)
{ {
@ -177,6 +179,31 @@ namespace HeavenStudio.Editor
eventsParent.GetChild(index).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.EventSelectedCol.Hex2RGB(); eventsParent.GetChild(index).GetComponent<TMP_Text>().color = EditorTheme.theme.properties.EventSelectedCol.Hex2RGB();
} }
public bool IsPointerOverUIElement()
{
return IsPointerOverUIElement(GetEventSystemRaycastResults());
}
private bool IsPointerOverUIElement(List<RaycastResult> eventSystemRaysastResults)
{
for (int index = 0; index < eventSystemRaysastResults.Count; index++)
{
RaycastResult curRaysastResult = eventSystemRaysastResults[index];
if (curRaysastResult.gameObject.layer == 5)
return true;
}
return false;
}
static List<RaycastResult> GetEventSystemRaycastResults()
{
PointerEventData eventData = new PointerEventData(EventSystem.current);
eventData.position = Input.mousePosition;
List<RaycastResult> raysastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(eventData, raysastResults);
return raysastResults;
}
#endregion #endregion
#region Events #region Events