Vec3InputField 2
e 按·(esc下面那个)暂时关闭UI
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using JetBrains.Annotations;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements.Experimental;
|
||||
@@ -9,47 +11,58 @@ public class DynamicUIVec3InputField : DynamicUIElement
|
||||
public TMP_InputField inputFieldx;
|
||||
public TMP_InputField inputFieldy;
|
||||
public TMP_InputField inputFieldz;
|
||||
Transform objtransform;
|
||||
|
||||
|
||||
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);
|
||||
objtransform = connectedGameElement.transform;
|
||||
Vector3 pos = (Vector3)objtransform.GetType().GetProperty(parameterName).GetValue(objtransform);
|
||||
|
||||
Vector3 pos = (Vector3)e.GetType().GetField(parameterName).GetValue(e); //获取对应变量的值
|
||||
|
||||
|
||||
inputFieldx.text =pos.x.ToString();
|
||||
inputFieldx.onEndEdit.AddListener(ApplyParametersx);
|
||||
|
||||
inputFieldy.text =pos.y.ToString();
|
||||
inputFieldx.onEndEdit.AddListener(ApplyParametersy);
|
||||
|
||||
inputFieldz.text =pos.z.ToString();
|
||||
inputFieldx.onEndEdit.AddListener(ApplyParametersz);
|
||||
|
||||
}//我不应该用这种复制大法的(
|
||||
|
||||
private void ApplyParametersx(string text)
|
||||
public void ApplyParametersx(string text)
|
||||
{
|
||||
Vector3 newpos=totramsf(float.Parse(text),0);
|
||||
transform.GetType().GetProperty(parameterName).SetValue(objtransform,newpos);
|
||||
|
||||
Vector3 newpos=totramsf(text,0);
|
||||
e.GetType().GetField(parameterName).SetValue(e, newpos);
|
||||
|
||||
}
|
||||
private void ApplyParametersy(string text)
|
||||
public void ApplyParametersy(string text)
|
||||
{
|
||||
Vector3 newpos=totramsf(float.Parse(text),1);
|
||||
transform.GetType().GetProperty(parameterName).SetValue(objtransform,newpos);
|
||||
|
||||
Vector3 newpos=totramsf(text,1);
|
||||
e.GetType().GetField(parameterName).SetValue(e, newpos);
|
||||
}
|
||||
private void ApplyParametersz(string text)
|
||||
public void ApplyParametersz(string text)
|
||||
{
|
||||
Vector3 newpos=totramsf(float.Parse(text),2);
|
||||
transform.GetType().GetProperty(parameterName).SetValue(objtransform,newpos);
|
||||
|
||||
Vector3 newpos=totramsf(text,2);
|
||||
e.GetType().GetField(parameterName).SetValue(e, newpos);
|
||||
}
|
||||
|
||||
Vector3 totramsf(float value,int queue){
|
||||
Vector3 a= (Vector3)transform.GetType().GetProperty(parameterName).GetValue(connectedGameElement.transform);
|
||||
switch(queue){
|
||||
case 0:a.x=value;break;
|
||||
case 1:a.y=value;break;
|
||||
case 2:a.z=value;break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,13 +63,13 @@ namespace Ichni.Editor
|
||||
|
||||
for (int i = 1; i <= this.tabLayer; i++)
|
||||
{
|
||||
float lineX = 30 * i;
|
||||
float lineX = 30 * i;
|
||||
Instantiate(indentationLinePrefab, tabRect).GetComponent<RectTransform>().anchoredPosition = new Vector2(lineX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float posX = -5 + 30 * tabLayer;
|
||||
float posX = -25 +( 30 * tabLayer);
|
||||
tabMainRect.anchoredPosition = new Vector2(posX, tabMainRect.anchoredPosition.y);
|
||||
|
||||
tabButton.onClick.AddListener(SelectGameElement);
|
||||
@@ -125,9 +125,9 @@ namespace Ichni.Editor
|
||||
{
|
||||
if (!expand && isExpanded)
|
||||
{
|
||||
foreach (var tab in childTabList)
|
||||
for(int i=childTabList.Count;i>0;i--)
|
||||
{
|
||||
tab.SetExpansion(expand); //false
|
||||
childTabList[i-1].SetExpansion(expand); //false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Ichni.Editor
|
||||
containers.Clear();
|
||||
connectedGameElement = gameElement;
|
||||
connectedGameElement.SetUpInspector();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user