sth
做了点功能 bug在冰花那张谱里
This commit is contained in:
@@ -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)
|
||||
{
|
||||
//我什么也不做
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user