45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
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");
|
|
}
|
|
}
|
|
} |