奇怪的调

This commit is contained in:
2025-06-14 20:47:45 +08:00
parent 970ee90a8b
commit 338ae9bddd
22 changed files with 20470 additions and 2681 deletions

View File

@@ -261,5 +261,70 @@ namespace Ichni.Editor
}
Debug.Log("===== =====");
}
public static void SetNoteHLInGame(bool forceSetOff = false, bool SameTheme = false)
{
var noteBases = EditorManager.instance.beatmapContainer.gameElementList.OfType<NoteBase>().ToList();
// 先全部关闭高亮如果forceSetOff为true
if (forceSetOff)
{
foreach (var note in noteBases)
{
note.noteVisual.isHighlighted = false;
note.noteVisual.SetHighlight();
}
}
// 按时间分组
var groups = SameTheme
? noteBases.GroupBy(n => (object)new { n.exactJudgeTime, Type = n.GetType() })
: noteBases.GroupBy(n => (object)n.exactJudgeTime);
foreach (var group in groups)
{
if (group.Count() > 1)
{
foreach (var note in group)
{
note.noteVisual.isHighlighted = true;
note.noteVisual.SetHighlight();
}
}
}
}
public static void SetNoteHLInElement(bool forceSetOff = false, bool SameTheme = false)
{
var noteBases = inspector.connectedGameElement.GetAllGameElementsFromThis().OfType<NoteBase>().ToList();
// 先全部关闭高亮如果forceSetOff为true
if (forceSetOff)
{
foreach (var note in noteBases)
{
note.noteVisual.isHighlighted = false;
note.noteVisual.SetHighlight();
}
}
// 按时间分组
var groups = SameTheme
? noteBases.GroupBy(n => (object)new { n.exactJudgeTime, Type = n.GetType() })
: noteBases.GroupBy(n => (object)n.exactJudgeTime);
foreach (var group in groups)
{
if (group.Count() > 1)
{
foreach (var note in group)
{
note.noteVisual.isHighlighted = true;
note.noteVisual.SetHighlight();
}
}
}
}
}
}

View File

@@ -36,35 +36,52 @@ namespace Ichni.Editor
public Vector2 vector2;
public void FindTab(GameElement targetElement, bool findparent = false)
{
if (findparent && targetElement.connectedTab != null)
{
targetElement.connectedTab.expandButton.onClick.Invoke();
return;
}
else if (targetElement.connectedTab != null)
{
targetElement.connectedTab.tabButton.onClick.Invoke();
}
else
{
FindTab(targetElement.parentElement, true);
if (!findparent)
{
targetElement.connectedTab.tabButton.onClick.Invoke();
}
else
{
targetElement.connectedTab.expandButton.onClick.Invoke();
return;
}
//targetElement.SetUpInspector();
StartCoroutine(TryGetTab(targetElement));
}
public IEnumerator TryGetTab(GameElement targetElement)
{
StandardInspectionElement.GenerateForLoading();
// 1. 向上找到最近的有Tab的祖先
Stack<GameElement> stack = new Stack<GameElement>();
GameElement current = targetElement;
while (current != null && current.connectedTab == null)
{
stack.Push(current);
current = current.parentElement;
}
HierarchyTab tab = targetElement.connectedTab;
float Tablocalpos = (-tab.transform.localPosition.y) - (tabContainer.sizeDelta.y / 4f);
// 2. 如果有Tab的祖先存在依次展开回目标
HierarchyTab parentTab = current != null ? current.connectedTab : null;
while (stack.Count > 0)
{
var elem = stack.Pop();
// 只展开父Tab不直接生成Tab
if (elem.parentElement != null && elem.parentElement.connectedTab != null && !elem.parentElement.connectedTab.isExpanded)
{
elem.parentElement.connectedTab.ExpandOrFold();
yield return null;
}
// 等待当前elem的Tab生成
while (elem.connectedTab == null)
{
yield return null;
}
parentTab = elem.connectedTab;
}
// 3. 等待目标Tab实例化
while (targetElement.connectedTab == null)
{
yield return null;
}
HierarchyTab finalTab = targetElement.connectedTab;
float Tablocalpos = (-finalTab.transform.localPosition.y) - (tabContainer.sizeDelta.y / 4f);
float pct = Tablocalpos / tabContainer.sizeDelta.y;
scrollRect.verticalNormalizedPosition = 1f - pct;
finalTab.SelectGameElement();
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using Ichni.RhythmGame;
using Michsky.MUIP;
using Sirenix.Utilities;
@@ -83,7 +84,8 @@ namespace Ichni.Editor
}
public void SetStatus()
{
expandButton.interactable = !connectedGameElement.childElementList.IsNullOrEmpty();
//expandButton.interactable = !connectedGameElement.childElementList.IsNullOrEmpty();
}
}
@@ -124,20 +126,18 @@ namespace Ichni.Editor
EditorManager.instance.timeline.SetTimeLine(connectedGameElement);
}
private void ExpandOrFold()
public void ExpandOrFold()
{
this.childTabList.RemoveAll(s => s == null);
isExpanded = !isExpanded;
StartCoroutine(ExpandAnim());
ExpandAnim();
if (isExpanded)
{
float startTime = Time.realtimeSinceStartup;
connectedGameElement.childElementList.Sort();//TODO: 后续可以让玩家手动快速排序
Debug.Log("排序耗时 " + (Time.realtimeSinceStartup - startTime).ToString());
StartCoroutine(ExpandOverTime());
for (var index = 0; index < connectedGameElement.childElementList.Count; index++)
{
var childElement = connectedGameElement.childElementList[index];
EditorManager.instance.uiManager.hierarchy.GenerateTab(childElement, connectedGameElement);
}
}
else
{
@@ -167,16 +167,25 @@ namespace Ichni.Editor
EditorManager.instance.uiManager.hierarchy.tabList.Remove(this);
}
}
private IEnumerator ExpandAnim()
private void ExpandAnim()
{
expandButton.transform.DORotate(new Vector3(0, 0, !isExpanded ? 0f : 180f), 0.2f);
}
private IEnumerator ExpandOverTime()//帧率过低的时候等一下再实例化
{
for (int i = 0; i < 10; i++)
float startTime = Time.realtimeSinceStartup;
for (var index = 0; index < connectedGameElement.childElementList.Count; index++)
{
expandButton.transform.GetComponentInChildren<TMP_Text>().rectTransform.localRotation =
Quaternion.Euler(0, 0, isExpanded ? 18 * i : 180 - 18 * i);
yield return null;
int hasYield = 0;
while (Time.realtimeSinceStartup - startTime > 1f / EditorManager.instance.editorSettings.frameRate * 3f && hasYield <= 2)
{
yield return null;
hasYield += 1;
}
var childElement = connectedGameElement.childElementList[index];
EditorManager.instance.uiManager.hierarchy.GenerateTab(childElement, connectedGameElement);
}
expandButton.transform.GetComponentInChildren<TMP_Text>().rectTransform.localRotation = Quaternion.Euler(0, 0, isExpanded ? 180 : 0);
}
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using UnityEngine;
namespace Ichni.Editor
{
public static class StandardInspectionElement
{
private static IHaveInspection inspector => EditorManager.instance.uiManager.inspector;
private static Inspector inspectorUI => EditorManager.instance.uiManager.inspector;
public static void GenerateForTransform(GameElement gameElement, DynamicUIContainer generateContainer = null)//关于有Transform
{
if (generateContainer is null)
{
generateContainer = inspector.GenerateContainer("Generate Elements");
}
var animationSubcontainer = generateContainer.GenerateSubcontainer(3);
var displacementButton = inspector.GenerateButton(gameElement, animationSubcontainer, "Displacement", () =>
{
Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, gameElement,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //位移
var swirlButton = inspector.GenerateButton(gameElement, animationSubcontainer, "Swirl", () =>
{
Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, gameElement,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //旋转
var scaleButton = inspector.GenerateButton(gameElement, animationSubcontainer, "Scale", () =>
{
Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true, gameElement,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //缩放
}
public static void GenerateForLoading()
{
inspectorUI.ClearInspector();
var container = inspector.GenerateContainer("Loading");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97779e95563721b4e8d4a28bb0d46cb9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -56,7 +56,7 @@ namespace Ichni.RhythmGame
var crossTrackPoint = inspector.GenerateButton(this, generateBase, "Cross Track Point",
() => CrossTrackPoint.GenerateElement("New Cross Track Point", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleInt(), new FlexibleFloat()));
StandardInspectionElement.GenerateForTransform(this, container); //关于有Transform的元素
var generateNote = container.GenerateSubcontainer(3);
var tapButton = inspector.GenerateButton(this, generateNote, "Tap",
() => Tap.GenerateElement("New Tap", Guid.NewGuid(), new List<string>(), true, this, 0f));
@@ -76,18 +76,7 @@ namespace Ichni.RhythmGame
() => TimeEffectsCollection.GenerateElement("New Time Effects Collection", Guid.NewGuid(),
new List<string>(), true, this, 0));
var generateAnimation = container.GenerateSubcontainer(3);
var displacementButton = inspector.GenerateButton(this, generateAnimation, "Displacement",
() => Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var swirlButton = inspector.GenerateButton(this, generateAnimation, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var scaleButton = inspector.GenerateButton(this, generateAnimation, "Scale", () =>
{
Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //缩放
}
}

View File

@@ -15,7 +15,7 @@ namespace Ichni.RhythmGame
public static EnvironmentObject GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement, bool isStatic)
{
EnvironmentObject environmentObject =
EnvironmentObject environmentObject =
SubstantialObject.GenerateElement(elementName, id, tags, isFirstGenerated, themeBundleName, objectName, parentElement)
.GetComponent<EnvironmentObject>();
@@ -30,34 +30,26 @@ namespace Ichni.RhythmGame
{
public override void SaveBM()
{
matchedBM = new EnvironmentObject_BM(elementName, elementGuid, tags,
matchedBM = new EnvironmentObject_BM(elementName, elementGuid, tags,
parentElement.matchedBM as GameElement_BM, themeBundleName, objectName, isStatic);
}
public override void SetUpInspector()
{
base.SetUpInspector();
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Generate");
var objectSettings = container.GenerateSubcontainer(3);
var environmentObjectButton = inspector.GenerateButton(this, objectSettings, "Environment Object",
() => TemporaryObject.GenerateElement("New Environment Object", Guid.NewGuid(), new List<string>(),
true, this));
var isStaticToggle = inspector.GenerateToggle(this, objectSettings, "Is Static", nameof(isStatic))
.AddListenerFunction(() => gameObject.isStatic = isStatic);
StandardInspectionElement.GenerateForTransform(this, container); //关于有Transform的元素
var generateAnimation = container.GenerateSubcontainer(3);
var generateDisplacementButton = inspector.GenerateButton(this, generateAnimation, "Displacement",
() => Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var generateSwirlButton = inspector.GenerateButton(this, generateAnimation, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var generateScaleButton = inspector.GenerateButton(this, generateAnimation, "Scale",
() => Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var generateBaseColorChangeButton = inspector.GenerateButton(this, generateAnimation, "Base Color Change",
() => BaseColorChange.GenerateElement("New Base Color Change", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
@@ -67,7 +59,7 @@ namespace Ichni.RhythmGame
() => EmissionColorChange.GenerateElement("New Emission Color Change", Guid.NewGuid(), new List<string>(), true,
this, new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
}
}
}
@@ -92,12 +84,12 @@ namespace Ichni.RhythmGame
public override void ExecuteBM()
{
matchedElement = EnvironmentObject.GenerateElement(elementName, elementGuid, tags, false,
themeBundleName, objectName,GetElement(attachedElementGuid), isStatic);
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic);
}
public override GameElement DuplicateBM(GameElement parent)
{
return EnvironmentObject.GenerateElement(elementName, Guid.NewGuid(), tags, false,
return EnvironmentObject.GenerateElement(elementName, Guid.NewGuid(), tags, false,
themeBundleName, objectName, parent, isStatic);
}
}

View File

@@ -68,13 +68,9 @@ namespace Ichni.RhythmGame
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
base.SetUpInspector();
var container = inspector.GenerateContainer("Generate");
StandardInspectionElement.GenerateForTransform(this, container); //关于有Transform的元素
var generateAnimation = container.GenerateSubcontainer(3);
var displacementButton = inspector.GenerateButton(this, generateAnimation, "Displacement",
() => Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var swirlButton = inspector.GenerateButton(this, generateAnimation, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var extensionButton = inspector.GenerateButton(this, generateAnimation, "Extension",
() => GameCameraExtension.GenerateElement("New Extension", Guid.NewGuid(),

View File

@@ -160,9 +160,28 @@ namespace Ichni.RhythmGame
}
public override void SetUpInspector()
{
base.SetUpInspector();
//
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Element Info");
//基础信息
var info = container.GenerateSubcontainer(3);
var nameInputField = inspector.GenerateInputField(this, info, GetType().Name + "'s Name", nameof(elementName));
var guidText = inspector.GenerateParameterText(this, info, "Element GUID", nameof(elementGuid));
var tagsListButton = inspector.GenerateButton(this, info, "Tags List", () =>
{
inspector.GenerateCompositeParameterWindow(this, "Tags List", nameof(tags)).SetAsStringList();
});
if (noteVisual != null)
{
noteVisual.transformSubmodule.SetUpInspector();
}
//次级模块
foreach (var submodule in submoduleList)
{
submodule.SetUpInspector();
}
//为了设置便捷Transform编辑手动更改原方法而不是用Base
var infoContainer = inspector.GenerateContainer("Note Info");
var noteBaseSettings = infoContainer.GenerateSubcontainer(3);

View File

@@ -50,21 +50,10 @@ namespace Ichni.RhythmGame
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Generate");
var generateAnimation = container.GenerateSubcontainer(3);
var displacementButton = inspector.GenerateButton(this, generateAnimation, "Displacement",
() => Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var swirlButton = inspector.GenerateButton(this, generateAnimation, "Swirl",
() => Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat()));
var scaleButton = inspector.GenerateButton(this, generateAnimation, "Scale", () =>
{
Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //缩放
StandardInspectionElement.GenerateForTransform(this, container);
var settings = inspector.GenerateContainer("Settings");
var settingsSubcontainer = container.GenerateSubcontainer(3);
var settingsSubcontainer = settings.GenerateSubcontainer(3);
var highlightToggle =
inspector.GenerateToggle(this, settingsSubcontainer, "Highlight", nameof(isHighlighted))
.AddListenerFunction(SetHighlight);

View File

@@ -162,24 +162,24 @@ namespace Ichni.RhythmGame
var flickButton = inspector.GenerateButton(this, noteSubcontainer, "Flick",
() => { Flick.GenerateElement("New Flick", Guid.NewGuid(), new List<string>(), true, this, 0f, new List<Vector2>()); }); //Note Flick
StandardInspectionElement.GenerateForTransform(this, generateContainer); //关于有Transform的元素
// var animationSubcontainer = generateContainer.GenerateSubcontainer(3);
// var displacementButton = inspector.GenerateButton(this, animationSubcontainer, "Displacement", () =>
// {
// Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, this,
// new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
// }); //位移
var animationSubcontainer = generateContainer.GenerateSubcontainer(3);
var displacementButton = inspector.GenerateButton(this, animationSubcontainer, "Displacement", () =>
{
Displacement.GenerateElement("New Displacement", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //位移
var swirlButton = inspector.GenerateButton(this, animationSubcontainer, "Swirl", () =>
{
Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //旋转
var scaleButton = inspector.GenerateButton(this, animationSubcontainer, "Scale", () =>
{
Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true, this,
new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
}); //缩放
// var swirlButton = inspector.GenerateButton(this, animationSubcontainer, "Swirl", () =>
// {
// Swirl.GenerateElement("New Swirl", Guid.NewGuid(), new List<string>(), true, this,
// new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
// }); //旋转
// var scaleButton = inspector.GenerateButton(this, animationSubcontainer, "Scale", () =>
// {
// Scale.GenerateElement("New Scale", Guid.NewGuid(), new List<string>(), true, this,
// new FlexibleFloat(), new FlexibleFloat(), new FlexibleFloat());
// }); //缩放
if (trackPathSubmodule != null)
{
trackPathButton.button.interactable = false;

View File

@@ -69,6 +69,7 @@ namespace Ichni.RhythmGame
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
StandardInspectionElement.GenerateForTransform(this); //关于有Transform的元素
var container = inspector.GenerateContainer("Trail");

View File

@@ -123,7 +123,7 @@ namespace Ichni.Editor
List<Vector3> newPositions = new List<Vector3>();
// 添加距离检测逻辑
bool withinDistance = Vector3.Distance(sceneCamera.transform.position, point) <= 100f;
bool withinDistance = Vector3.Distance(sceneCamera.transform.position, point) <= 50f;
for (float x = minX; x <= maxX; x += step)
{

View File

@@ -11,7 +11,7 @@ namespace Ichni.Editor
public class GridController : MonoBehaviour, IBaseElement
{
public BaseElement_BM matchedBM { get; set; }
public EditorGrid yPlaneGrid;
public EditorGrid xPlaneGrid;
public EditorGrid zPlaneGrid;
@@ -34,18 +34,18 @@ namespace Ichni.Editor
public void SetUpInspector()
{
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
var container = inspector.GenerateContainer("Grid Controller");
//网格设置
var gridSettings = container.GenerateSubcontainer(3);
var yPlaneToggle =
var yPlaneToggle =
inspector.GenerateToggle(this, gridSettings, "Y Plane", nameof(yPlaneEnabled))
.AddListenerFunction(RefreshPlanes);
var xPlaneToggle =
var xPlaneToggle =
inspector.GenerateToggle(this, gridSettings, "X Plane", nameof(xPlaneEnabled))
.AddListenerFunction(RefreshPlanes);
var zPlaneToggle =
var zPlaneToggle =
inspector.GenerateToggle(this, gridSettings, "Z Plane", nameof(zPlaneEnabled))
.AddListenerFunction(RefreshPlanes);
@@ -60,7 +60,7 @@ namespace Ichni.Editor
xPlaneGrid.gameObject.SetActive(xPlaneEnabled);
zPlaneGrid.gameObject.SetActive(zPlaneEnabled);
yPlaneGrid.isShowingPositionText = isYPlaneShowingPositionText;
if (!yPlaneGrid.isShowingPositionText)
{
foreach (KeyValuePair<GameObject, Vector3> positionText in yPlaneGrid.positionTexts)