@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
@@ -16,59 +13,64 @@ namespace Ichni.Editor
|
||||
public EditorGrid xPlaneGrid;
|
||||
public EditorGrid zPlaneGrid;
|
||||
|
||||
public bool yPlaneEnabled;
|
||||
public bool xPlaneEnabled;
|
||||
public bool zPlaneEnabled;
|
||||
[Header("State")]
|
||||
public bool yPlaneEnabled = true;
|
||||
public bool xPlaneEnabled = false;
|
||||
public bool zPlaneEnabled = false;
|
||||
public bool isYPlaneShowingPositionText = true;
|
||||
public float fixedTextSizeFactor = 0.1f;
|
||||
|
||||
public bool isYPlaneShowingPositionText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
yPlaneEnabled = true;
|
||||
xPlaneEnabled = false;
|
||||
zPlaneEnabled = false;
|
||||
isYPlaneShowingPositionText = true;
|
||||
RefreshPlanes();
|
||||
}
|
||||
|
||||
public void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
var container = inspector.GenerateContainer("Grid Controller");
|
||||
|
||||
//网格设置
|
||||
var gridSettings = container.GenerateSubcontainer(3);
|
||||
var yPlaneToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "Y Plane", nameof(yPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
var xPlaneToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "X Plane", nameof(xPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
var zPlaneToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "Z Plane", nameof(zPlaneEnabled))
|
||||
|
||||
inspector.GenerateToggle(this, gridSettings, "Y Plane (XZ)", nameof(yPlaneEnabled))
|
||||
.AddListenerFunction(RefreshPlanes);
|
||||
|
||||
var yPlaneShowPositionToggle =
|
||||
inspector.GenerateToggle(this, gridSettings, "Show Y Plane Position", nameof(isYPlaneShowingPositionText))
|
||||
.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()
|
||||
{
|
||||
yPlaneGrid.gameObject.SetActive(yPlaneEnabled);
|
||||
xPlaneGrid.gameObject.SetActive(xPlaneEnabled);
|
||||
zPlaneGrid.gameObject.SetActive(zPlaneEnabled);
|
||||
yPlaneGrid.isShowingPositionText = isYPlaneShowingPositionText;
|
||||
SetGridState(yPlaneGrid, yPlaneEnabled, isYPlaneShowingPositionText);
|
||||
SetGridState(xPlaneGrid, xPlaneEnabled, false); // 假设其他平面暂时不显示文字
|
||||
SetGridState(zPlaneGrid, zPlaneEnabled, false);
|
||||
}
|
||||
|
||||
if (!yPlaneGrid.isShowingPositionText)
|
||||
private void SetGridState(EditorGrid grid, bool active, bool showText)
|
||||
{
|
||||
if (grid == null) return;
|
||||
|
||||
grid.gameObject.SetActive(active);
|
||||
|
||||
if (active)
|
||||
{
|
||||
foreach (KeyValuePair<GameObject, Vector3> positionText in yPlaneGrid.positionTexts)
|
||||
{
|
||||
LeanPool.Despawn(positionText.Key);
|
||||
}
|
||||
grid.canShowPositionText = showText;
|
||||
grid.isShowingPositionText = showText;
|
||||
|
||||
yPlaneGrid.positionTexts.Clear();
|
||||
// 如果关闭了文字显示,立刻清理
|
||||
if (!showText)
|
||||
{
|
||||
grid.ClearAllTexts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user