Files
ichni_Creator_Studio/Assets/Scripts/DynamicUI/DynamicUIElements/DynamicUIVec3InputField.cs
TRAfoer 3a1ee5f9ef Vec3InputField 2
e
按·(esc下面那个)暂时关闭UI
2025-02-12 21:29:40 +08:00

71 lines
2.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using JetBrains.Annotations;
using TMPro;
using UnityEngine;
using UnityEngine.UIElements.Experimental;
namespace Ichni.Editor{
public class DynamicUIVec3InputField : DynamicUIElement
{
public TMP_InputField inputFieldx;
public TMP_InputField inputFieldy;
public TMP_InputField inputFieldz;
public TransformSubmodule e=null;
public override void Initialize(string title, string parameterName)
{
foreach(var i in connectedGameElement.submoduleList){
if(i.GetType()==typeof(TransformSubmodule)){
e= (TransformSubmodule)i;
break;
}
}
if (e == null)Destroy(gameObject);
base.Initialize(title, parameterName);
Vector3 pos = (Vector3)e.GetType().GetField(parameterName).GetValue(e); //获取对应变量的值
inputFieldx.text =pos.x.ToString();
inputFieldy.text =pos.y.ToString();
inputFieldz.text =pos.z.ToString();
}//我不应该用这种复制大法的(
public void ApplyParametersx(string text)
{
Vector3 newpos=totramsf(text,0);
e.GetType().GetField(parameterName).SetValue(e, newpos);
}
public void ApplyParametersy(string text)
{
Vector3 newpos=totramsf(text,1);
e.GetType().GetField(parameterName).SetValue(e, newpos);
}
public void ApplyParametersz(string text)
{
Vector3 newpos=totramsf(text,2);
e.GetType().GetField(parameterName).SetValue(e, newpos);
}
Vector3 totramsf(string value,int queue){
float avalue;
if(!float.TryParse(value,out avalue)){
avalue=0f;
}
Vector3 a= (Vector3)e.GetType().GetField(parameterName).GetValue(e); //获取对应变量的值
a[queue]=avalue;
return a;
}
}
}