做了点功能
bug在冰花那张谱里
This commit is contained in:
2025-03-30 11:18:37 +08:00
parent 188f05182b
commit 30fab16eed
8 changed files with 1070 additions and 415 deletions

View File

@@ -6,6 +6,8 @@ using JetBrains.Annotations;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
using UnityEngine.UIElements.Experimental;
@@ -25,7 +27,7 @@ namespace Ichni.Editor
if (parameterName != string.Empty)
{
ApplyContent();
inputFieldX.onEndEdit.AddListener(_ => ApplyParameters());
inputFieldY.onEndEdit.AddListener(_ => ApplyParameters());
inputFieldZ.onEndEdit.AddListener(_ => ApplyParameters());
@@ -35,15 +37,48 @@ namespace Ichni.Editor
private void Update()
{
(this as IHaveAutoUpdate).UpdateContent();
// 检测鼠标是否在 inputFieldX、inputFieldY 或 inputFieldZ 上
var selectedGameObject = EventSystem.current.currentSelectedGameObject;
bool[] isMouseOverText = new[]
{
selectedGameObject==inputFieldX.gameObject,
selectedGameObject==inputFieldY.gameObject,selectedGameObject == inputFieldZ.gameObject
};
if (Mouse.current.scroll.ReadValue().y != 0) // 检测鼠标滚轮
{
float scrollDelta = Mouse.current.scroll.ReadValue().y > 0 ? 0.1f : -0.1f; // 根据滚轮方向设置增量
if (isMouseOverText[0]) // 鼠标在 inputFieldX 上
{
float currentValue = float.Parse(inputFieldX.text);
inputFieldX.text = (currentValue + scrollDelta).ToString();
ApplyParameters();
}
else if (isMouseOverText[1]) // 鼠标在 inputFieldY 上
{
float currentValue = float.Parse(inputFieldY.text);
inputFieldY.text = (currentValue + scrollDelta).ToString();
ApplyParameters();
}
else if (isMouseOverText[2]) // 鼠标在 inputFieldZ 上
{
float currentValue = float.Parse(inputFieldZ.text);
inputFieldZ.text = (currentValue + scrollDelta).ToString();
ApplyParameters();
}
}
}
public void SetDefaultValue(Vector3 value)
{
inputFieldX.text = value.x.ToString();
inputFieldY.text = value.y.ToString();
inputFieldZ.text = value.z.ToString();
}
public Vector3 GetValue()
{
return new Vector3(float.Parse(inputFieldX.text), float.Parse(inputFieldY.text), float.Parse(inputFieldZ.text));
@@ -53,11 +88,11 @@ namespace Ichni.Editor
{
isAutoUpdate = enable;
isReceiving = true;
inputFieldX.onSelect.AddListener(_ => isReceiving = false);
inputFieldY.onSelect.AddListener(_ => isReceiving = false);
inputFieldZ.onSelect.AddListener(_ => isReceiving = false);
inputFieldX.onDeselect.AddListener(_ => isReceiving = true);
inputFieldY.onDeselect.AddListener(_ => isReceiving = true);
inputFieldZ.onDeselect.AddListener(_ => isReceiving = true);
@@ -70,22 +105,23 @@ namespace Ichni.Editor
inputFieldY.text = pos.y.ToString();
inputFieldZ.text = pos.z.ToString();
}
private void ApplyParameters()
{
Vector3 newValue = new Vector3(float.Parse(inputFieldX.text), float.Parse(inputFieldY.text), float.Parse(inputFieldZ.text));
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, newValue);
connectedBaseElement.Refresh();
}
public override void AddListenerFunction(UnityAction action)
{
inputFieldX.onEndEdit.AddListener(_ => action());
inputFieldY.onEndEdit.AddListener(_ => action());
inputFieldZ.onEndEdit.AddListener(_ => action());
}
public override void DeviverSet(int i){
public override void DeviverSet(int i)
{
//我什么也不做
}
}

View File

@@ -30,7 +30,7 @@ namespace Ichni.RhythmGame
baseColorChange.animationReturnType = FlexibleReturnType.Before;
baseColorChange.targetColorSubmodule = (animatedObject as IHaveColorSubmodule).colorSubmodule;
//baseColorChange.timeDurationSubmodule.SetDuration(colorR, colorG, colorB, colorA);
return baseColorChange;
@@ -48,13 +48,13 @@ namespace Ichni.RhythmGame
colorB.UpdateFlexibleFloat(songTime);
colorA.UpdateFlexibleFloat(songTime);
if ((colorR.returnType is FlexibleReturnType.MiddleExecuting || colorR.isSwitchingReturnType) ||
(colorG.returnType is FlexibleReturnType.MiddleExecuting || colorG.isSwitchingReturnType) ||
(colorB.returnType is FlexibleReturnType.MiddleExecuting || colorB.isSwitchingReturnType) ||
if ((colorR.returnType is FlexibleReturnType.MiddleExecuting || colorR.isSwitchingReturnType) ||
(colorG.returnType is FlexibleReturnType.MiddleExecuting || colorG.isSwitchingReturnType) ||
(colorB.returnType is FlexibleReturnType.MiddleExecuting || colorB.isSwitchingReturnType) ||
(colorA.returnType is FlexibleReturnType.MiddleExecuting || colorA.isSwitchingReturnType))
{
animationReturnType = FlexibleReturnType.MiddleExecuting;
targetColorSubmodule.currentBaseColor = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
targetColorSubmodule.baseColorDirtyMark = true;
}
@@ -63,7 +63,7 @@ namespace Ichni.RhythmGame
animationReturnType = FlexibleReturnType.MiddleInterval;
}
}
public override void ApplyTimeOffset(float offset)
{
base.ApplyTimeOffset(offset);
@@ -98,6 +98,12 @@ namespace Ichni.RhythmGame
{
inspector.GenerateCompositeParameterWindow(this, "Color A", nameof(colorA)).SetAsFlexibleFloat();
});
var graphicEditor = inspector.GenerateButton(this, container, "GraphicEditor",
() =>
{
inspector.GenerateGraphicalFlexibleFloatWindow(this, "Displacement",
new FlexibleFloat[] { colorR, colorG, colorB, colorA }, new string[] { "R", "G", "B", "A" });
});
container.SetDeviver(1);
}
}
@@ -107,7 +113,7 @@ namespace Ichni.RhythmGame
public override void SaveBM()
{
matchedBM = new BaseColorChange_BM(elementName, elementGuid, tags,
animatedObject.matchedBM as GameElement_BM, colorR.ConvertToBM(),
animatedObject.matchedBM as GameElement_BM, colorR.ConvertToBM(),
colorG.ConvertToBM(), colorB.ConvertToBM(), colorA.ConvertToBM());
}
}

View File

@@ -9,14 +9,14 @@ namespace Ichni.Editor
public class OperationManager
{
public GameElement currentSelectedElement { get; private set; }
public CopyPasteDeleteModule CopyPasteDeleteModule;
public OperationManager()
{
CopyPasteDeleteModule = new CopyPasteDeleteModule();
}
public void SelectElement(GameElement gameElement)
{
if (currentSelectedElement != null)
@@ -30,7 +30,7 @@ namespace Ichni.Editor
currentSelectedElement = gameElement;
currentSelectedElement.connectedTab.isSelected = true;
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f,0.5f, 0.5f, 0.2f);
currentSelectedElement.connectedTab.BgImage.color = new Color(0.5f, 0.5f, 0.5f, 0.2f);
}
}
@@ -44,7 +44,7 @@ namespace Ichni.Editor
LogWindow.Log("Copied element: " + gameElement.elementName);
copiedElement = gameElement;
}
public void PasteElement(GameElement parentElement)
{
if (copiedElement == null)
@@ -52,24 +52,25 @@ namespace Ichni.Editor
LogWindow.Log("No element copied.");
return;
}
LogWindow.Log("Pasted element: " + copiedElement.elementName + " to " + parentElement.elementName);
pastedElementList = new List<GameElement>();
AffiliatedPaste(copiedElement, parentElement);
}
public void DeleteElement(GameElement gameElement)
{
LogWindow.Log("Deleted element: " + gameElement.elementName + " and all its children.");
if (gameElement.parentElement != null)
{
gameElement.parentElement.childElementList.Remove(gameElement); //从父物体的子物体列表中移除避免报null
gameElement.parentElement.connectedTab.childTabList.Remove(gameElement.connectedTab);
}
gameElement.Delete();
}
/// <summary>
/// 使用递归的方式复制粘贴物体及其所有子物体
/// </summary>
@@ -88,7 +89,7 @@ namespace Ichni.Editor
submodule.SaveBM();
(submodule.matchedBM as Submodule_BM).DuplicateBM(pastedElement);
});
if (gameElement.childElementList != null)
{
for (int i = 0; i < gameElement.childElementList.Count; i++)