点击预览位置,alt——上下挪动位置

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2026-02-13 17:40:50 +08:00
parent c21dc74576
commit 96a2c60e16
34 changed files with 23940 additions and 211416 deletions

View File

@@ -556,7 +556,8 @@ namespace ichni.RhythmGame // [修复] 修正命名空间首字母大写,符
}
public static FastNoteTracker GenerateElement(string elementName, Guid id, List<string> tags,
bool isFirstGenerated, GameElement parentElement)
bool isFirstGenerated, GameElement parentElement,
bool isEnabled = true, bool showNotePreview = false, float horizonWidth = 5f, int beatDiver = 1)
{
FastNoteTracker fastNoteTracker = Instantiate(EditorManager.instance.basePrefabs.emptyObject, parentElement.transform)
.AddComponent<FastNoteTracker>();
@@ -566,6 +567,10 @@ namespace ichni.RhythmGame // [修复] 修正命名空间首字母大写,符
return null;
}
fastNoteTracker.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
fastNoteTracker.IsEnabled = isEnabled;
fastNoteTracker.showNotePreview = showNotePreview;
fastNoteTracker.horizonWidth = horizonWidth;
fastNoteTracker.BeatDiver = beatDiver;
return fastNoteTracker;
}
@@ -574,10 +579,23 @@ namespace ichni.RhythmGame // [修复] 修正命名空间首字母大写,符
base.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
//parentElement.refreshAction += AdjustBeatLine;
}
public override void AfterInitialize()
{
Observable.NextFrame().Subscribe(_ => Refresh());
}
public override void SaveBM()
{
matchedBM = new FastNoteTracker_BM(elementName, elementGuid, tags, parentElement.elementGuid);
matchedBM = new FastNoteTracker_BM(
elementName,
elementGuid,
tags,
parentElement.elementGuid,
IsEnabled,
showNotePreview,
horizonWidth,
BeatDiver
);
}
}
}
@@ -586,12 +604,21 @@ namespace Ichni.RhythmGame.Beatmap
{
public class FastNoteTracker_BM : GameElement_BM
{
public FastNoteTracker_BM(string elementName, Guid id, List<string> tags, Guid attachedElementGuid)
public bool IsEnabled { get; set; }
public bool showNotePreview { get; set; }
public float horizonWidth { get; set; }
public int beatDiver { get; set; }
public FastNoteTracker_BM(string elementName, Guid id, List<string> tags, Guid attachedElementGuid, bool IsEnabled, bool showNotePreview, float horizonWidth, int beatDiver)
{
this.elementName = elementName;
this.elementGuid = id;
this.tags = tags;
this.attachedElementGuid = attachedElementGuid;
this.IsEnabled = IsEnabled;
this.showNotePreview = showNotePreview;
this.horizonWidth = horizonWidth;
this.beatDiver = beatDiver;
}
public override GameElement DuplicateBM(GameElement attached)

View File

@@ -95,15 +95,10 @@ public class PanelDrawer : MonoBehaviour //暂时支持xz
public Canvas DisplayCanvas;
private IEnumerator Pressing()
{
GameObject gobj = new GameObject("PanelDrawerPreview");
RawImage rawImage = gobj.AddComponent<RawImage>();
GameObject gobj2 = new GameObject("PanelDrawerText");
gobj2.transform.SetParent(gobj.transform, false);
gobj2.transform.SetParent(DisplayCanvas.transform, false);
TextMeshProUGUI Text = gobj2.AddComponent<TextMeshProUGUI>();
Text.rectTransform.position = new Vector3(50, 50, 0);
rawImage.texture = ingTexture;
rawImage.rectTransform.SetParent(DisplayCanvas.transform);
rawImage.rectTransform.sizeDelta = new Vector2(100, 100);
Vector3 hitPoint = new Vector3(0, 0, 0);
while (Mouse.current.leftButton.isPressed)
{
@@ -117,21 +112,23 @@ public class PanelDrawer : MonoBehaviour //暂时支持xz
if (Keyboard.current.leftAltKey.isPressed)
{
hitPoint = new Vector3(Mathf.Round(hitPoint.x / 0.5f) * 0.5f, hitPoint.y, Mathf.Round(hitPoint.z / 0.5f) * 0.5f);
rawImage.rectTransform.position =
new Vector3(Mathf.Round(Mouse.current.position.ReadValue().x / 10) * 10, Mathf.Round(Mouse.current.position.ReadValue().y / 10) * 10, 0);
}
else
{
rawImage.rectTransform.position = Mouse.current.position.ReadValue();
}
Text.text = $"X: {hitPoint.x:F2}\nY: {hitPoint.y:F2}\nZ: {hitPoint.z:F2}";
Text.rectTransform.position = Mouse.current.position.ReadValue() + new Vector2(20, -20);
Text.text = $"X: {hitPoint.x:F2}\nZ: {hitPoint.z:F2}\n\n";
Text.fontSize = 45;
Text.color = Color.yellow;
}
yield return null;
}
Destroy(rawImage.gameObject);
Destroy(Text.gameObject);
var i = PathNode.GenerateElement("new pathnode", Guid.NewGuid(), new List<string>(), true, (Track)connectedGameElement, true);
i.transformSubmodule.originalPosition = hitPoint;
i.transform.position = hitPoint;
i.transformSubmodule.originalPosition = i.transform.localPosition;
i.Refresh();
connectedGameElement.Refresh();
}

View File

@@ -61,6 +61,8 @@ namespace Ichni.Editor
if (isMoving) return;
transform.eulerAngles = targetGameElement.parentElement?.transform.eulerAngles ?? Vector3.zero;
transform.position = targetGameElement.transform.position;
transform.localScale = //相机距离的函数,保持在一定大小范围内
Vector3.one * Mathf.Clamp(Vector3.Distance(editorCamera.transform.position, transform.position) * 0.05f, 0.1f, 1000f);
if (Mouse.current.leftButton.wasPressedThisFrame)
{
Vector2 mousePosition = Mouse.current.position.ReadValue();