Files
ichni_Creator_Studio/Assets/Scripts/EditorGame/Grids/GridController.cs

75 lines
2.5 KiB
C#
Raw Normal View History

2025-04-04 15:29:03 -04:00
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Ichni.RhythmGame.Beatmap;
2025-04-16 08:33:34 -04:00
using Lean.Pool;
2025-04-04 15:29:03 -04:00
using UnityEngine;
namespace Ichni.Editor
{
public class GridController : MonoBehaviour, IBaseElement
{
public BaseElement_BM matchedBM { get; set; }
2025-06-14 20:47:45 +08:00
2025-04-04 15:29:03 -04:00
public EditorGrid yPlaneGrid;
public EditorGrid xPlaneGrid;
public EditorGrid zPlaneGrid;
public bool yPlaneEnabled;
public bool xPlaneEnabled;
public bool zPlaneEnabled;
2025-04-16 08:33:34 -04:00
public bool isYPlaneShowingPositionText;
2025-04-04 15:29:03 -04:00
private void Start()
{
yPlaneEnabled = true;
xPlaneEnabled = false;
zPlaneEnabled = false;
2025-04-16 08:33:34 -04:00
isYPlaneShowingPositionText = true;
2025-04-04 15:29:03 -04:00
RefreshPlanes();
}
public void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
2025-06-14 20:47:45 +08:00
2025-04-04 15:29:03 -04:00
var container = inspector.GenerateContainer("Grid Controller");
2025-06-14 20:47:45 +08:00
2025-04-14 17:49:47 -04:00
//网格设置
var gridSettings = container.GenerateSubcontainer(3);
2025-06-14 20:47:45 +08:00
var yPlaneToggle =
2025-04-14 17:49:47 -04:00
inspector.GenerateToggle(this, gridSettings, "Y Plane", nameof(yPlaneEnabled))
.AddListenerFunction(RefreshPlanes);
2025-06-14 20:47:45 +08:00
var xPlaneToggle =
2025-04-16 08:33:34 -04:00
inspector.GenerateToggle(this, gridSettings, "X Plane", nameof(xPlaneEnabled))
.AddListenerFunction(RefreshPlanes);
2025-06-14 20:47:45 +08:00
var zPlaneToggle =
2025-04-14 17:49:47 -04:00
inspector.GenerateToggle(this, gridSettings, "Z Plane", nameof(zPlaneEnabled))
.AddListenerFunction(RefreshPlanes);
2025-04-16 08:33:34 -04:00
var yPlaneShowPositionToggle =
inspector.GenerateToggle(this, gridSettings, "Show Y Plane Position", nameof(isYPlaneShowingPositionText))
2025-04-14 17:49:47 -04:00
.AddListenerFunction(RefreshPlanes);
2025-04-04 15:29:03 -04:00
}
private void RefreshPlanes()
{
yPlaneGrid.gameObject.SetActive(yPlaneEnabled);
xPlaneGrid.gameObject.SetActive(xPlaneEnabled);
zPlaneGrid.gameObject.SetActive(zPlaneEnabled);
2025-04-16 08:33:34 -04:00
yPlaneGrid.isShowingPositionText = isYPlaneShowingPositionText;
2025-06-14 20:47:45 +08:00
2025-04-16 08:33:34 -04:00
if (!yPlaneGrid.isShowingPositionText)
{
foreach (KeyValuePair<GameObject, Vector3> positionText in yPlaneGrid.positionTexts)
{
LeanPool.Despawn(positionText.Key);
}
yPlaneGrid.positionTexts.Clear();
}
2025-04-04 15:29:03 -04:00
}
}
}