ar_tourism_flutter_unity/unity/VRProject2/Assets/zhl/zhlScripts/CeShi.cs
2025-05-14 17:04:13 +08:00

35 lines
986 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CeShi : MonoBehaviour
{
public Slider sliderGaoDu;
public GameObject ziYuan;
// Start is called before the first frame update
void Start()
{
// 添加滑动条值改变时的监听器
sliderGaoDu.onValueChanged.AddListener(OnGaoDuChanged);
}
// Update is called once per frame
void Update()
{
//sliderGaoDu.transform.GetChild(3).GetComponent<Text>().text = "大小" + sliderGaoDu.value.ToString("F1");
}
// 高度改变时的回调函数
private void OnGaoDuChanged(float value)
{
// 更新文本显示
sliderGaoDu.transform.GetChild(3).GetComponent<Text>().text = "宽" + sliderGaoDu.value* 12.5f+"高"+sliderGaoDu.value* 20;
// 根据滑块值改变ziYuan的缩放
ziYuan.transform.localScale = new Vector3(value * 2.5f, value * 1.6f, 4f*value);
}
}