@@ -45,7 +45,7 @@ namespace Ichni.RhythmGame
|
||||
public GameObject highPassFilterEffect;
|
||||
|
||||
[Title("Inspector相关")] public GameObject inspectorSecondaryWindow;
|
||||
|
||||
[Title("编辑器描边Material")] public Material outlineShaderMaterial;
|
||||
[Title("DynamicUI相关-Simple")] public GameObject dynamicUIContainer;
|
||||
public GameObject dynamicUISubcontainer;
|
||||
public GameObject inputField;
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace Ichni
|
||||
}
|
||||
public float CurrentFrameRate;
|
||||
public TMP_Text FPStext;
|
||||
public TMP_Text UIText;
|
||||
private IEnumerator StartFrameRate()
|
||||
{
|
||||
int frameCount = 0;
|
||||
@@ -115,6 +116,7 @@ namespace Ichni
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isLoaded) projectManager.autoSaveManager.UpdateAutoSave();
|
||||
@@ -131,7 +133,7 @@ namespace Ichni
|
||||
{
|
||||
projectManager.loadManager.LoadExport(projectName);
|
||||
}
|
||||
|
||||
|
||||
musicPlayer.audioSource.clip = songInformation.song;
|
||||
beatmapContainer.gameElementList.ForEach(gameElement =>
|
||||
{
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace Ichni.Editor
|
||||
private List<SelectionConnector> lastHitConnectors = new List<SelectionConnector>();
|
||||
private int currentSelectIndex = 0;
|
||||
|
||||
|
||||
private Vector2 lastMousePosition;
|
||||
private bool cachedIsPointerOverUI;
|
||||
private GameObject cachedHoveredUI;
|
||||
private int uiCheckFrameInterval = 3; // 每3帧检查一次
|
||||
private int frameCount;
|
||||
private int frameCount = 0;
|
||||
private const int uiCheckFrameInterval = 5; // 每隔多少帧强制检查一次UI
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -46,17 +46,9 @@ namespace Ichni.Editor
|
||||
Vector2 currentMousePosition = Mouse.current.position.ReadValue();
|
||||
if (currentMousePosition != lastMousePosition || frameCount % uiCheckFrameInterval == 0)
|
||||
{
|
||||
isPointerOverUI = IsPointerOverUI(out hoveredUI);
|
||||
lastMousePosition = currentMousePosition;
|
||||
cachedIsPointerOverUI = isPointerOverUI;
|
||||
cachedHoveredUI = hoveredUI;
|
||||
isPointerOverUI = IsPointerOverUI(out hoveredUI);
|
||||
}
|
||||
else
|
||||
{
|
||||
isPointerOverUI = cachedIsPointerOverUI;
|
||||
hoveredUI = cachedHoveredUI;
|
||||
}
|
||||
|
||||
SceneCameraOperation();
|
||||
MusicPlayerOperation();
|
||||
TracksOperation();
|
||||
@@ -314,17 +306,13 @@ namespace Ichni.Editor
|
||||
|
||||
public partial class InputListener
|
||||
{
|
||||
private TMP_Text UIText => EditorManager.instance.UIText;
|
||||
|
||||
public bool IsPointerOverUI(out GameObject hoveredUI)
|
||||
{
|
||||
hoveredUI = null;
|
||||
|
||||
// 快速检查 - 使用Unity内置方法
|
||||
if (!EventSystem.current.IsPointerOverGameObject())
|
||||
return false;
|
||||
|
||||
// 详细检查 - 只有当快速检查通过时才执行
|
||||
if (eventSystem == null || graphicRaycasters.Count == 0)
|
||||
return false;
|
||||
if (Mouse.current == null) return false;
|
||||
|
||||
pointerEventData = new PointerEventData(eventSystem)
|
||||
{
|
||||
@@ -333,21 +321,55 @@ namespace Ichni.Editor
|
||||
|
||||
List<RaycastResult> allResults = new List<RaycastResult>();
|
||||
|
||||
// 只对最上层的Canvas进行检测
|
||||
foreach (var raycaster in graphicRaycasters.Where(r => r.gameObject.activeInHierarchy))
|
||||
// 使用EventSystem的RaycastAll来确保检测所有UI
|
||||
EventSystem.current.RaycastAll(pointerEventData, allResults);
|
||||
|
||||
// 或者手动检测所有GraphicRaycaster
|
||||
foreach (var raycaster in FindObjectsOfType<GraphicRaycaster>())
|
||||
{
|
||||
if (!raycaster.enabled || !raycaster.gameObject.activeInHierarchy)
|
||||
continue;
|
||||
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
raycaster.Raycast(pointerEventData, results);
|
||||
|
||||
if (results.Count > 0)
|
||||
{
|
||||
// 找到最前面的结果后立即返回
|
||||
results.Sort((a, b) => b.sortingOrder.CompareTo(a.sortingOrder));
|
||||
hoveredUI = results[0].gameObject;
|
||||
return true;
|
||||
}
|
||||
allResults.AddRange(results);
|
||||
}
|
||||
|
||||
// 移除无效结果
|
||||
allResults.RemoveAll(r =>
|
||||
r.gameObject == null ||
|
||||
!r.gameObject.activeInHierarchy ||
|
||||
!r.gameObject.GetComponent<RectTransform>());
|
||||
|
||||
if (allResults.Count > 0)
|
||||
{
|
||||
// 完整排序
|
||||
allResults.Sort((a, b) =>
|
||||
{
|
||||
// 先按sorting layer
|
||||
int layerCompare = SortingLayer.GetLayerValueFromID(b.sortingLayer)
|
||||
.CompareTo(SortingLayer.GetLayerValueFromID(a.sortingLayer));
|
||||
if (layerCompare != 0) return layerCompare;
|
||||
|
||||
// 再按sorting order
|
||||
int orderCompare = b.sortingOrder.CompareTo(a.sortingOrder);
|
||||
if (orderCompare != 0) return orderCompare;
|
||||
|
||||
// 最后按depth
|
||||
return b.depth.CompareTo(a.depth);
|
||||
});
|
||||
|
||||
hoveredUI = allResults[0].gameObject;
|
||||
string text = $"UI: {hoveredUI.name}, Layer: {SortingLayer.IDToName(allResults[0].sortingLayer)}, Order: {allResults[0].sortingOrder}";
|
||||
if (UIText.text != text)
|
||||
{
|
||||
UIText.text = text;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
UIText.text = "No UI";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Ichni.Editor
|
||||
public class OperationManager
|
||||
{
|
||||
public List<GameElement> currentSelectedElements { get; private set; }
|
||||
|
||||
public TempOutlineModule TempOutlineModule = new TempOutlineModule();
|
||||
public CopyPasteDeleteModule CopyPasteDeleteModule;
|
||||
|
||||
public FindingModule FindingModule;
|
||||
@@ -59,7 +59,30 @@ namespace Ichni.Editor
|
||||
currentSelectedElements.Clear();
|
||||
}
|
||||
}
|
||||
public class TempOutlineModule
|
||||
{
|
||||
public List<GameElement> outlinedElements;
|
||||
public Material outlineMaterial => EditorManager.instance.basePrefabs.outlineShaderMaterial;
|
||||
public TempOutlineModule()
|
||||
{
|
||||
outlinedElements = new List<GameElement>();
|
||||
}
|
||||
|
||||
public void AddOutline(GameElement gameElement)
|
||||
{
|
||||
outlinedElements.Add(gameElement);
|
||||
}
|
||||
|
||||
public void RemoveOutline(GameElement gameElement)
|
||||
{
|
||||
outlinedElements.Remove(gameElement);
|
||||
}
|
||||
|
||||
public void ClearOutline()
|
||||
{
|
||||
outlinedElements.Clear();
|
||||
}
|
||||
}
|
||||
public class FindingModule
|
||||
{
|
||||
public GameElement FindGameElementByName(string elementName)
|
||||
|
||||
Reference in New Issue
Block a user