fix:风机初始化代码提交

This commit is contained in:
zhangjiajia
2026-05-20 17:05:47 +08:00
parent 8510a3dcda
commit 9579356ed1
3752 changed files with 1351544 additions and 1 deletions

View File

@@ -0,0 +1,63 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class OneKeyOperation : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void AllOpen()
{
foreach(Transform child in transform.Find("Sliders").transform)
{
StartCoroutine(SmoothIncreaseToTwo(0.3f, child));
}
}
public void AllClose()
{
foreach (Transform child in transform.Find("Sliders").transform)
{
StartCoroutine(SmoothDecreaseToZero(0.3f, child));
}
}
IEnumerator SmoothDecreaseToZero(float duration,Transform child )
{
float startValue = child.GetComponent<Slider>().value;
float time = 0f;
while (time < duration)
{
time += Time.deltaTime;
startValue = Mathf.Lerp(startValue, 0f, time / duration);
child.GetComponent<Slider>().value = startValue;
yield return null;
}
child.GetComponent<Slider>().value = 0f;
}
IEnumerator SmoothIncreaseToTwo(float duration, Transform child)
{
float startValue = child.GetComponent<Slider>().value;
float time = 0f;
while (time < duration)
{
time += Time.deltaTime;
startValue = Mathf.Lerp(startValue, 2f, time / duration);
child.GetComponent<Slider>().value = startValue;
yield return null;
}
child.GetComponent<Slider>().value = 2f;
}
}