Files
3d-qiaozha/Assets/Scripts/ChangeDownStreamLevel.cs
2026-03-10 10:07:11 +08:00

22 lines
519 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChangeDownStreamLevel : MonoBehaviour
{
private Vector3 originalPos;
// 高度范围(根据需要设置)
public void Start()
{
originalPos = transform.position;
}
// 直接在Inspector中绑定到Slider的OnValueChanged
public void OnSliderValueChanged(float value)
{
// 计算高度将0-1的Slider值映射到高度范围
transform.position = originalPos + new Vector3(0f, value, 0f);
}
}