@@ -55,7 +55,7 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
SetParent(parentElement);
|
||||
EditorManager.instance.uiManager.hierarchy.GenerateTab(this, parentElement);
|
||||
if (parentElement == null || parentElement.connectedTab != null) EditorManager.instance.uiManager.hierarchy.GenerateTab(this, parentElement);
|
||||
gameObject.name = elementName;
|
||||
//GameManager.beatMapContainer.beatMapElementList.Add(this);
|
||||
//serialNumber = totalSerialNumber++;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ichni.RhythmGame
|
||||
public Material skyboxMaterial;
|
||||
public string backgroundSpriteName;
|
||||
public Sprite backgroundSprite;
|
||||
|
||||
|
||||
public SkyboxSubsetter skyboxSubsetter;
|
||||
|
||||
public static BackgroundSetter GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
@@ -28,7 +28,7 @@ namespace Ichni.RhythmGame
|
||||
LogWindow.Log("There is already a Background Setter in the scene.", Color.red);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
BackgroundSetter backgroundSetter = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
|
||||
.AddComponent<BackgroundSetter>();
|
||||
EditorManager.instance.backgroundSetter = backgroundSetter;
|
||||
@@ -39,7 +39,7 @@ namespace Ichni.RhythmGame
|
||||
backgroundSetter.backgroundSpriteName = backgroundSpriteName;
|
||||
return backgroundSetter;
|
||||
}
|
||||
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
EditorManager.instance.backgroundController.EnableBackground(!useSkybox);
|
||||
@@ -61,33 +61,79 @@ namespace Ichni.RhythmGame
|
||||
matchedBM = new BackgroundSetter_BM(elementName, elementGuid, tags, null,
|
||||
useSkybox, skyboxThemeBundleName, skyboxMaterialName, backgroundSpriteName);
|
||||
}
|
||||
// 新增:用于在 Inspector 中显示的列表数据
|
||||
[HideInInspector] private List<string> themeBundleListForSelection;
|
||||
[HideInInspector] private List<string> skyboxNameListForSelection;
|
||||
private void UpdateSelectionLists()
|
||||
{
|
||||
themeBundleListForSelection = ThemeBundleManager.instance.loadedThemeBundleList.ConvertAll(x => x.themeBundleName);
|
||||
skyboxNameListForSelection = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(skyboxThemeBundleName) &&
|
||||
ThemeBundleManager.instance.TryGetThemeBundle(skyboxThemeBundleName, out ThemeBundle themeBundle))
|
||||
{
|
||||
skyboxNameListForSelection = themeBundle.assetList_Material.ConvertAll(x => x.name);
|
||||
}
|
||||
}
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector; // 引用主检查器用于刷新
|
||||
|
||||
var container = inspector.GenerateContainer("Background Setter");
|
||||
var backgroundSettings = container.GenerateSubcontainer(3);
|
||||
|
||||
// 1. 开关
|
||||
var useSkyboxToggle = inspector.GenerateToggle(this, backgroundSettings, "Use Skybox", nameof(useSkybox));
|
||||
var skyboxThemeBundleField = inspector.GenerateInputField(this, backgroundSettings, "Skybox Theme Bundle", nameof(skyboxThemeBundleName));
|
||||
var skyboxMaterialNameField = inspector.GenerateInputField(this, backgroundSettings, "Skybox Material", nameof(skyboxMaterialName));
|
||||
|
||||
// 刷新可选列表
|
||||
UpdateSelectionLists();
|
||||
|
||||
// 2. 天空盒资源包下拉框 (同步 SkyboxSubsetter 逻辑)
|
||||
var themeDropdown = inspector.GenerateDropdown(this, backgroundSettings, "Skybox Theme Bundle",
|
||||
themeBundleListForSelection, nameof(skyboxThemeBundleName));
|
||||
|
||||
themeDropdown.AddListenerFunction(() =>
|
||||
{
|
||||
UpdateSelectionLists();
|
||||
inspectorMain.SetInspector(this); // 选择包后刷新 UI 以加载材质列表
|
||||
});
|
||||
|
||||
// 3. 天空盒材质下拉框 (同步 SkyboxSubsetter 逻辑)
|
||||
var materialDropdown = inspector.GenerateDropdown(this, backgroundSettings, "Skybox Material",
|
||||
skyboxNameListForSelection, nameof(skyboxMaterialName));
|
||||
|
||||
if (string.IsNullOrEmpty(skyboxThemeBundleName) || skyboxNameListForSelection.Count == 0)
|
||||
{
|
||||
materialDropdown.dropdown.interactable = false;
|
||||
}
|
||||
|
||||
// 4. 背景图片输入框 (保持原样)
|
||||
var backgroundSpriteField = inspector.GenerateInputField(this, backgroundSettings, "Background Sprite", nameof(backgroundSpriteName));
|
||||
|
||||
// 5. 应用按钮
|
||||
var applyButton = inspector.GenerateButton(this, backgroundSettings, "Apply", Refresh);
|
||||
|
||||
void SetInputFields(bool value) // 根据是否使用Skybox设置输入框的可交互性
|
||||
// 控制交互性
|
||||
void SetInputFields(bool value)
|
||||
{
|
||||
skyboxThemeBundleField.inputField.interactable = value;
|
||||
skyboxMaterialNameField.inputField.interactable = value;
|
||||
themeDropdown.dropdown.interactable = value;
|
||||
materialDropdown.dropdown.interactable = value && !string.IsNullOrEmpty(skyboxThemeBundleName);
|
||||
backgroundSpriteField.inputField.interactable = !value;
|
||||
}
|
||||
|
||||
SetInputFields(useSkybox);
|
||||
|
||||
useSkyboxToggle.AddListenerFunction(() => EditorManager.instance.backgroundController.EnableBackground(!useSkybox));
|
||||
useSkyboxToggle.AddListenerFunction(() => SetInputFields(useSkybox));
|
||||
|
||||
var generateContainer = inspector.GenerateContainer("Generate");
|
||||
useSkyboxToggle.AddListenerFunction(() =>
|
||||
{
|
||||
EditorManager.instance.backgroundController.EnableBackground(!useSkybox);
|
||||
SetInputFields(useSkybox);
|
||||
});
|
||||
|
||||
// 生成 Skybox Subsetter 的按钮部分
|
||||
var generateContainer = inspector.GenerateContainer("Advanced Controls");
|
||||
var generateSubContainer = generateContainer.GenerateSubcontainer(3);
|
||||
var generateSkyboxControllerButton = inspector.GenerateButton(this, generateSubContainer, "Skybox Controller", () =>
|
||||
inspector.GenerateButton(this, generateSubContainer, "Create Skybox Controller", () =>
|
||||
{
|
||||
if (skyboxSubsetter == null)
|
||||
{
|
||||
@@ -153,7 +199,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override GameElement DuplicateBM(GameElement attached)
|
||||
{
|
||||
return BackgroundSetter.GenerateElement(elementName, Guid.NewGuid(), tags, false, attached,
|
||||
return BackgroundSetter.GenerateElement(elementName, Guid.NewGuid(), tags, false, attached,
|
||||
useSkybox, skyboxThemeBundleName, skyboxMaterialName, backgroundSpriteName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,9 @@ namespace Ichni.RhythmGame
|
||||
Vector3 normal = Quaternion.Euler(transformSubmodule.currentEulerAngles) * Vector3.up;
|
||||
float size = transformSubmodule.currentScale.x;
|
||||
Color color = colorSubmodule.currentBaseColor;
|
||||
|
||||
MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
|
||||
materialPropertyBlock.SetColor("_Color", color);
|
||||
pathNodeSphere.GetComponent<Renderer>()?.SetPropertyBlock(materialPropertyBlock);
|
||||
transform.localPosition = position;
|
||||
transform.localRotation = Quaternion.LookRotation(normal);
|
||||
transform.localScale = Vector3.one * size;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4d99b225afe249449c426683cb3e513
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,326 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame; // 假设 LeanPool 引用在这里或 Lean.Pool 命名空间
|
||||
using Lean.Pool; // 引入 LeanPool
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
[RequireComponent(typeof(MeshRenderer))]
|
||||
public class EditorGrid : MonoBehaviour
|
||||
{
|
||||
public GridController gridController;
|
||||
[Header("Camera Settings")]
|
||||
public Camera sceneCamera;
|
||||
|
||||
[Header("Grid Configuration")]
|
||||
[Tooltip("0 = XZ, 1 = XY, 2 = YZ")]
|
||||
public int gridPlane = 0;
|
||||
public float baseScale = 1f;
|
||||
public float scaleMultiplier = 1f;
|
||||
public float distanceFactor = 10f;
|
||||
|
||||
[Header("Text Settings")]
|
||||
public bool canShowPositionText;
|
||||
public bool isShowingPositionText;
|
||||
public Transform textContainer;
|
||||
public GameObject positionTextPrefab;
|
||||
|
||||
[Tooltip("启用此项可让文字在屏幕上保持固定大小")]
|
||||
public bool constantScreenSize = true;
|
||||
[Tooltip("屏幕固定大小的基准系数")]
|
||||
public float fixedTextSizeFactor => gridController != null ? gridController.fixedTextSizeFactor : 0.02f;
|
||||
|
||||
public float textUpdateFrequency = 0.1f;
|
||||
|
||||
// --- 运行时状态 ---
|
||||
private Material gridMaterial;
|
||||
private float cameraDistance;
|
||||
public float logScale;
|
||||
public float gridScale;
|
||||
|
||||
// --- 缓存与优化变量 ---
|
||||
private float lastTextUpdateTime;
|
||||
private Vector3 lastCameraPosition;
|
||||
private float lastGridScale;
|
||||
private Plane gridPlaneCache;
|
||||
private Vector2 screenCenter;
|
||||
|
||||
// 使用 Vector2Int 作为 Key,避免浮点数比较误差,同时实现 O(1) 查找
|
||||
// Key: 网格索引 (x index, z index), Value: 文本对象
|
||||
private Dictionary<Vector2Int, GameObject> activeTexts = new Dictionary<Vector2Int, GameObject>();
|
||||
|
||||
// 避免 GC 的复用容器
|
||||
private HashSet<Vector2Int> requiredIndices = new HashSet<Vector2Int>();
|
||||
private List<Vector2Int> toRemoveIndices = new List<Vector2Int>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
sceneCamera = EditorManager.instance.cameraManager.sceneCamera.sceneCamera;
|
||||
gridMaterial = GetComponent<MeshRenderer>().material;
|
||||
gridMaterial.SetFloat("_Plane", gridPlane);
|
||||
|
||||
// 设置 Shader 线宽
|
||||
float lineWidthOf3840 = 2;
|
||||
float lineWidth = lineWidthOf3840 * (Screen.width / 3840f);
|
||||
gridMaterial.SetFloat("_LineWidth", lineWidth);
|
||||
|
||||
screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
|
||||
UpdateGridPlaneCache();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// 获取当前相机
|
||||
if (EditorManager.instance?.cameraManager?.currentCamera != null)
|
||||
sceneCamera = EditorManager.instance.cameraManager.currentCamera;
|
||||
|
||||
if (sceneCamera == null) return;
|
||||
|
||||
CalculateGridScale();
|
||||
UpdateShaderParams();
|
||||
|
||||
if (canShowPositionText && isShowingPositionText)
|
||||
{
|
||||
// 检查是否需要更新网格位置(降低频率)
|
||||
bool shouldUpdate = Time.time - lastTextUpdateTime >= textUpdateFrequency ||
|
||||
Vector3.Distance(sceneCamera.transform.position, lastCameraPosition) > gridScale * 0.5f ||
|
||||
Mathf.Abs(gridScale - lastGridScale) > 0.1f;
|
||||
|
||||
if (shouldUpdate)
|
||||
{
|
||||
UpdateTextPositions();
|
||||
lastTextUpdateTime = Time.time;
|
||||
lastCameraPosition = sceneCamera.transform.position;
|
||||
lastGridScale = gridScale;
|
||||
}
|
||||
}
|
||||
else if (activeTexts.Count > 0)
|
||||
{
|
||||
ClearAllTexts();
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 LateUpdate 处理文字的朝向和缩放,防止画面抖动
|
||||
void LateUpdate()
|
||||
{
|
||||
if (!canShowPositionText || !isShowingPositionText || activeTexts.Count == 0) return;
|
||||
|
||||
UpdateTextVisuals();
|
||||
}
|
||||
|
||||
private void CalculateGridScale()
|
||||
{
|
||||
Vector3 camPos = sceneCamera.transform.position;
|
||||
Vector3 gridPos = transform.position;
|
||||
|
||||
cameraDistance = gridPlane switch
|
||||
{
|
||||
0 => Mathf.Abs(camPos.y - gridPos.y), // XZ
|
||||
1 => Mathf.Abs(camPos.z - gridPos.z), // XY
|
||||
2 => Mathf.Abs(camPos.x - gridPos.x), // YZ
|
||||
_ => cameraDistance
|
||||
};
|
||||
|
||||
logScale = Mathf.Floor(Mathf.Log(cameraDistance / distanceFactor + 1, 4));
|
||||
gridScale = baseScale * Mathf.Pow(4, logScale) * scaleMultiplier;
|
||||
}
|
||||
|
||||
private void UpdateShaderParams()
|
||||
{
|
||||
gridMaterial.SetFloat("_GridScale", 1 / gridScale);
|
||||
gridMaterial.SetFloat("_DisappearEndDistance", 100 * gridScale);
|
||||
}
|
||||
|
||||
#region 文本逻辑 (优化版)
|
||||
|
||||
private void UpdateTextPositions()
|
||||
{
|
||||
// 每次都获取最新的屏幕中心,保证中心点始终正确
|
||||
screenCenter = new Vector2(Screen.width / 2f, Screen.height / 2f);
|
||||
// 1. 射线检测找中心点
|
||||
Ray sceneCameraRay = sceneCamera.ScreenPointToRay(screenCenter);
|
||||
if (!gridPlaneCache.Raycast(sceneCameraRay, out float enter))
|
||||
{
|
||||
ClearAllTexts();
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 centerPoint = sceneCameraRay.GetPoint(enter);
|
||||
|
||||
// 距离剔除
|
||||
if (Vector3.Distance(sceneCamera.transform.position, centerPoint) > 200f) // 增加最大距离
|
||||
{
|
||||
ClearAllTexts();
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = gridScale * 12f; // 可视范围半径
|
||||
float step = gridScale * 4f; // 网格步长
|
||||
|
||||
// 2. 计算当前需要的网格索引范围
|
||||
requiredIndices.Clear();
|
||||
|
||||
// 根据不同的平面,取不同的轴进行计算
|
||||
float xLocal = 0, yLocal = 0;
|
||||
switch (gridPlane)
|
||||
{
|
||||
case 0: xLocal = centerPoint.x; yLocal = centerPoint.z; break; // XZ
|
||||
case 1: xLocal = centerPoint.x; yLocal = centerPoint.y; break; // XY
|
||||
case 2: xLocal = centerPoint.y; yLocal = centerPoint.z; break; // YZ (注意轴向)
|
||||
}
|
||||
|
||||
int minX = Mathf.FloorToInt((xLocal - radius) / step);
|
||||
int maxX = Mathf.CeilToInt((xLocal + radius) / step);
|
||||
int minY = Mathf.FloorToInt((yLocal - radius) / step);
|
||||
int maxY = Mathf.CeilToInt((yLocal + radius) / step);
|
||||
|
||||
for (int x = minX; x <= maxX; x++)
|
||||
{
|
||||
for (int y = minY; y <= maxY; y++)
|
||||
{
|
||||
requiredIndices.Add(new Vector2Int(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 移除不再需要的 (差集)
|
||||
toRemoveIndices.Clear();
|
||||
foreach (var kvp in activeTexts)
|
||||
{
|
||||
if (!requiredIndices.Contains(kvp.Key))
|
||||
{
|
||||
toRemoveIndices.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in toRemoveIndices)
|
||||
{
|
||||
LeanPool.Despawn(activeTexts[key]);
|
||||
activeTexts.Remove(key);
|
||||
}
|
||||
|
||||
// 4. 生成新增的
|
||||
foreach (var index in requiredIndices)
|
||||
{
|
||||
if (!activeTexts.ContainsKey(index))
|
||||
{
|
||||
SpawnTextAt(index, step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnTextAt(Vector2Int index, float step)
|
||||
{
|
||||
GameObject textObj = LeanPool.Spawn(positionTextPrefab, textContainer);
|
||||
|
||||
// 计算世界坐标
|
||||
Vector3 worldPos = Vector3.zero;
|
||||
float xPos = index.x * step;
|
||||
float yPos = index.y * step;
|
||||
|
||||
// 偏移量:稍微偏离网格线
|
||||
float offset = gridScale / 6f;
|
||||
|
||||
switch (gridPlane)
|
||||
{
|
||||
case 0: // XZ
|
||||
worldPos = new Vector3(xPos + offset, transform.position.y, yPos + offset);
|
||||
break;
|
||||
case 1: // XY
|
||||
worldPos = new Vector3(xPos + offset, yPos + offset, transform.position.z);
|
||||
break;
|
||||
case 2: // YZ -> 这里 index.x 对应 Y轴, index.y 对应 Z轴 (视具体需求调整)
|
||||
worldPos = new Vector3(transform.position.x, xPos + offset, yPos + offset);
|
||||
break;
|
||||
}
|
||||
|
||||
textObj.transform.position = worldPos;
|
||||
|
||||
// 设置文本内容
|
||||
TMP_Text tmp = textObj.GetComponent<TMP_Text>();
|
||||
if (tmp) tmp.text = $"({Mathf.RoundToInt(xPos)}, {Mathf.RoundToInt(yPos)})";
|
||||
|
||||
activeTexts.Add(index, textObj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理朝向摄像机 和 动态大小
|
||||
/// </summary>
|
||||
private void UpdateTextVisuals()
|
||||
{
|
||||
Vector3 camPos = sceneCamera.transform.position;
|
||||
|
||||
foreach (var kvp in activeTexts)
|
||||
{
|
||||
GameObject obj = kvp.Value;
|
||||
if (obj == null) continue;
|
||||
|
||||
Transform t = obj.transform;
|
||||
float dist = Vector3.Distance(camPos, t.position);
|
||||
|
||||
// 1. 朝向摄像机
|
||||
t.LookAt(t.position + sceneCamera.transform.rotation * Vector3.forward,
|
||||
sceneCamera.transform.rotation * Vector3.up);
|
||||
|
||||
// 2. 动态计算大小
|
||||
if (constantScreenSize)
|
||||
{
|
||||
// 简单的透视投影公式:大小 = 距离 * 系数
|
||||
// 这样距离越远,物体本身越大,但在屏幕上看起来一样大
|
||||
float finalScale = dist * fixedTextSizeFactor;
|
||||
t.localScale = new Vector3(finalScale, finalScale, finalScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 原有的逻辑:随网格等级缩放
|
||||
float staticScale = gridScale * 1.5f;
|
||||
t.localScale = new Vector3(staticScale, staticScale, staticScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearAllTexts()
|
||||
{
|
||||
foreach (var obj in activeTexts.Values)
|
||||
{
|
||||
if (obj != null) LeanPool.Despawn(obj);
|
||||
}
|
||||
activeTexts.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void UpdateGridPlaneCache()
|
||||
{
|
||||
gridPlaneCache = gridPlane switch
|
||||
{
|
||||
0 => new Plane(Vector3.up, transform.position),
|
||||
1 => new Plane(Vector3.forward, transform.position),
|
||||
2 => new Plane(Vector3.right, transform.position),
|
||||
_ => new Plane(Vector3.up, transform.position)
|
||||
};
|
||||
}
|
||||
|
||||
public void SetGridPlane(int planeIndex)
|
||||
{
|
||||
gridPlane = planeIndex;
|
||||
gridMaterial.SetFloat("_Plane", gridPlane);
|
||||
UpdateGridPlaneCache();
|
||||
// 切换平面时强制刷新文字
|
||||
ClearAllTexts();
|
||||
lastTextUpdateTime = 0;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (gridMaterial != null)
|
||||
{
|
||||
if (Application.isEditor) DestroyImmediate(gridMaterial);
|
||||
else Destroy(gridMaterial);
|
||||
}
|
||||
// 场景销毁时,LeanPool 通常会自动清理,但手动清理引用是个好习惯
|
||||
activeTexts.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcf702d09b6611648a7df04aa49aa927
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,77 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab1e04d0e4926e748895c81bd8791147
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user