266 lines
8.5 KiB
C#
266 lines
8.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PostionController : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform targetTransform;
|
|
[SerializeField] private TMP_InputField offsetInputField;
|
|
[SerializeField] private TMP_InputField sizeInputField;
|
|
|
|
[SerializeField] private TMP_InputField xInputField;
|
|
[SerializeField] private TMP_InputField yInputField;
|
|
|
|
[SerializeField] private TMP_InputField high_InputField;
|
|
|
|
[SerializeField] private TMP_InputField cube_high_InputField;
|
|
[SerializeField] private TMP_InputField cube_xInputField;
|
|
[SerializeField] private TMP_InputField cube_zInputField;
|
|
[SerializeField] private TMP_InputField cube_HighOffset_InputField;
|
|
|
|
public GetKuangparent getKuangparent;
|
|
[SerializeField] private TMP_InputField maxDistance_InputField;
|
|
|
|
public Transform cubeTransform;
|
|
|
|
[SerializeField] private Slider slider;
|
|
[SerializeField] private TMP_Text sliderText;
|
|
|
|
public GPSTestRunner gPS;
|
|
|
|
[SerializeField] private Toggle toggle;
|
|
|
|
[SerializeField] private TMP_InputField bigHigh;
|
|
[SerializeField] private TMP_InputField smallHigh;
|
|
|
|
[SerializeField] private Transform[] bigs;
|
|
[SerializeField] private Transform[] smalls;
|
|
|
|
private Dictionary<Transform, float> bigKeyValuePairs = new();
|
|
private Dictionary<Transform, float> smallKeyValuePairs = new();
|
|
|
|
[SerializeField] private TMP_InputField qbLocal_xInputField;
|
|
[SerializeField] private TMP_InputField qbLocal_yInputField;
|
|
[SerializeField] private TMP_InputField qbScaleInputField;
|
|
[SerializeField] private Transform qb;
|
|
void Awake()
|
|
{
|
|
foreach(Transform big in bigs)
|
|
{
|
|
bigKeyValuePairs.Add(big,big.position.y);
|
|
}
|
|
foreach(Transform small in smalls)
|
|
{
|
|
smallKeyValuePairs.Add(small,small.position.y);
|
|
}
|
|
}
|
|
private void Start()
|
|
{
|
|
//GetData.Instance.GetToken("Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjNmMGM0YWIwLWI5OWEtNDlmNy1iZTU5LTkwMjY1MWFhYjBmYyJ9.Y08tPHYU2UH-Ih_tjSjOUc--tbsfNb-_hyYNN8CfqW2yaB1DpnxxYQmheywzCQHeMQJ-yaShnxUXEVi3PkmhCw");
|
|
offsetInputField.onEndEdit.AddListener(OnOffsetValueChanged);
|
|
sizeInputField.onEndEdit.AddListener(OnSizeValueChanged);
|
|
|
|
xInputField.onEndEdit.AddListener(OnXValueChanged);
|
|
yInputField.onEndEdit.AddListener(OnYValueChanged);
|
|
|
|
high_InputField.onEndEdit.AddListener(OnHighValueChanged);
|
|
|
|
cube_high_InputField.onEndEdit.AddListener(OnCubeHighValueChanged);
|
|
cube_xInputField.onEndEdit.AddListener(OnCubeXValueChanged);
|
|
cube_zInputField.onEndEdit.AddListener(OnCubeZValueChanged);
|
|
cube_HighOffset_InputField.onEndEdit.AddListener(OnCubeHighValueChanged);
|
|
maxDistance_InputField.onEndEdit.AddListener(OnMaxDistanceValueChanged);
|
|
slider.onValueChanged.AddListener(OnSliderValueChanged);
|
|
|
|
bigHigh.onEndEdit.AddListener(OnSetBigHigh);
|
|
smallHigh.onEndEdit.AddListener(OnSetSmallHigh);
|
|
//------------------------
|
|
//泉宝x轴位置和高度
|
|
qbLocal_xInputField.onEndEdit.AddListener(OnQbLocalXValueChanged);
|
|
qbLocal_yInputField.onEndEdit.AddListener(OnQbLocalYValueChanged);
|
|
qbScaleInputField.onEndEdit.AddListener(OnQbScaleValueChanged);
|
|
}
|
|
|
|
private void OnQbScaleValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float result))
|
|
{
|
|
qb.localScale = new Vector3(result, result, result);
|
|
}
|
|
}
|
|
|
|
private void OnQbLocalXValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out var result))
|
|
{
|
|
qb.localPosition = new Vector3(result, qb.localPosition.y, qb.localPosition.z);
|
|
}
|
|
}
|
|
|
|
private void OnQbLocalYValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out var result))
|
|
{
|
|
qb.localPosition = new Vector3(qb.localPosition.x, result, qb.localPosition.z);
|
|
}
|
|
}
|
|
|
|
private void OnSetBigHigh(string value)
|
|
{
|
|
if (float.TryParse(value, out float bigHigh))
|
|
{
|
|
foreach(var item in bigKeyValuePairs)
|
|
{
|
|
item.Key.position = new(item.Key.position.x,item.Key.position.y + bigHigh,item.Key.position.z);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
private void OnSetSmallHigh(string value)
|
|
{
|
|
if (float.TryParse(value, out float smallHigh))
|
|
{
|
|
foreach(var item in smallKeyValuePairs)
|
|
{
|
|
item.Key.position = new(item.Key.position.x,item.Key.position.y + smallHigh,item.Key.position.z);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
|
|
private void OnOffsetValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float offset))
|
|
{
|
|
targetTransform.position = new Vector3(offset, targetTransform.position.y, targetTransform.position.z);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
private void OnSizeValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float size))
|
|
{
|
|
targetTransform.localScale = new Vector3(size, size, size);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
private void OnXValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float x))
|
|
{
|
|
if (gPS != null)
|
|
{
|
|
gPS.targetGPS = new Vector2(x, gPS.targetGPS.y);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
private void OnYValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float y))
|
|
{
|
|
if (gPS != null)
|
|
{
|
|
gPS.targetGPS = new Vector2(gPS.targetGPS.x, y);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
private void OnHighValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float high))
|
|
{
|
|
gPS.targetObject.localPosition = new Vector3(gPS.targetObject.localPosition.x, high, gPS.targetObject.localPosition.z);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
|
|
private void OnCubeHighValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float cube_high))
|
|
{
|
|
if (float.TryParse(cube_HighOffset_InputField.text, out float cube_high_offset))
|
|
{
|
|
cubeTransform.localScale = new Vector3(cubeTransform.localScale.x, cube_high, cubeTransform.localScale.z);
|
|
cubeTransform.position = new Vector3(cubeTransform.position.x, cube_high / 2 + cube_high_offset, cubeTransform.position.z);
|
|
}
|
|
else
|
|
{
|
|
cubeTransform.localScale = new Vector3(cubeTransform.localScale.x, cube_high, cubeTransform.localScale.z);
|
|
cubeTransform.position = new Vector3(cubeTransform.position.x, cube_high / 2, cubeTransform.position.z);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
private void OnCubeXValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float cube_x))
|
|
{
|
|
cubeTransform.position = new Vector3(cube_x, cubeTransform.position.y, cubeTransform.position.z);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
private void OnCubeZValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float cube_z))
|
|
{
|
|
cubeTransform.position = new Vector3(cubeTransform.position.x, cubeTransform.position.y, cube_z);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
private void OnMaxDistanceValueChanged(string value)
|
|
{
|
|
if (float.TryParse(value, out float maxDistance))
|
|
{
|
|
getKuangparent.maxDistance = maxDistance;
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("输入的值不是数字");
|
|
}
|
|
}
|
|
private void OnSliderValueChanged(float value)
|
|
{
|
|
sliderText.text = value.ToString();
|
|
transform.GetChild(0).GetComponent<Camera>().fieldOfView = value;
|
|
//Debug.Log("fieldOfView:" + transform.GetChild(0).GetComponent<Camera>().fieldOfView);
|
|
}
|
|
} |