using System.Collections.Generic; using Ichni.RhythmGame; using Ichni.RhythmGame.Beatmap; using UnityEngine; namespace Ichni.Editor { public class GridController : MonoBehaviour, IBaseElement { public BaseElement_BM matchedBM { get; set; } public EditorGrid yPlaneGrid; public EditorGrid xPlaneGrid; public EditorGrid zPlaneGrid; [Header("State")] public bool yPlaneEnabled = true; public bool xPlaneEnabled = false; public bool zPlaneEnabled = false; public bool isYPlaneShowingPositionText = true; public float fixedTextSizeFactor = 0.1f; private void Start() { RefreshPlanes(); } public void SetUpInspector() { IHaveInspection inspector = EditorManager.instance.uiManager.inspector; var container = inspector.GenerateContainer("Grid Controller"); var gridSettings = container.GenerateSubcontainer(3); inspector.GenerateToggle(this, gridSettings, "Y Plane (XZ)", nameof(yPlaneEnabled)) .AddListenerFunction(RefreshPlanes); inspector.GenerateToggle(this, gridSettings, "X Plane (YZ)", nameof(xPlaneEnabled)) .AddListenerFunction(RefreshPlanes); inspector.GenerateToggle(this, gridSettings, "Z Plane (XY)", nameof(zPlaneEnabled)) .AddListenerFunction(RefreshPlanes); inspector.GenerateToggle(this, gridSettings, "Show Y Plane Pos", nameof(isYPlaneShowingPositionText)) .AddListenerFunction(RefreshPlanes); inspector.GenerateInputField(this, gridSettings, "Fixed Text Size Factor", nameof(fixedTextSizeFactor)) .AddListenerFunction(RefreshPlanes); } private void RefreshPlanes() { SetGridState(yPlaneGrid, yPlaneEnabled, isYPlaneShowingPositionText); SetGridState(xPlaneGrid, xPlaneEnabled, false); // 假设其他平面暂时不显示文字 SetGridState(zPlaneGrid, zPlaneEnabled, false); } private void SetGridState(EditorGrid grid, bool active, bool showText) { if (grid == null) return; grid.gameObject.SetActive(active); if (active) { grid.canShowPositionText = showText; grid.isShowingPositionText = showText; // 如果关闭了文字显示,立刻清理 if (!showText) { grid.ClearAllTexts(); } } } } }