fix:风机初始化代码提交
This commit is contained in:
45
Assets/Scripts/Sluices/ConnectToRealSluicesHeight.cs
Normal file
45
Assets/Scripts/Sluices/ConnectToRealSluicesHeight.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ConnectToRealSluicesHeight : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class SluicesSliderBinding
|
||||
{
|
||||
public GameObject sluice;
|
||||
public GameObject slider;
|
||||
}
|
||||
|
||||
public List<SluicesSliderBinding> bindings = new List<SluicesSliderBinding>();
|
||||
|
||||
private Dictionary<GameObject, Vector3> sluiceInitialLocalPosition = new Dictionary<GameObject, Vector3>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
foreach (var binding in bindings)
|
||||
{
|
||||
sluiceInitialLocalPosition[binding.sluice] = binding.sluice.transform.localPosition;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
foreach (var binding in bindings)
|
||||
{
|
||||
Slider sliderComp = binding.slider.GetComponent<Slider>();
|
||||
Vector3 initLocalPos = sluiceInitialLocalPosition[binding.sluice];
|
||||
|
||||
binding.sluice.transform.localPosition = new Vector3(
|
||||
initLocalPos.x,
|
||||
initLocalPos.y + sliderComp.value,
|
||||
initLocalPos.z
|
||||
);
|
||||
|
||||
binding.slider.transform.Find("Text (TMP)").GetComponent<TextMeshProUGUI>().text =
|
||||
binding.slider.name.Substring(6) + "#" + ": " + sliderComp.value.ToString("F1");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user