Unity 滑动条 SlideView
using UnityEngine; using System.Collections; using UnityEngine.UI; public class SlideView : MonoBehaviour { public Slider slide; public Scrollbar sb; // Use this for initialization void Start() { if (transform.name == "Scrollbar Horizontal") { slide.value = 1; sb.value = 0; slide.onValueChanged.AddListener((v) => { sb.value = 1 - slide.value; }); sb.onValueChanged.AddListener((v) => { slide.value = 1 - sb.value; }); return; } slide.value = 0; sb.value = 1; slide.onValueChanged.AddListener((v) => { sb.value = (1 - slide.value); }); sb.onValueChanged.AddListener((v) => { slide.value = (1 - sb.value); }); } //private void OnEnable() //{ // slide.gameObject.SetActive(true); //} //private void OnDisable() //{ // slide.gameObject.SetActive(false); //} //// Update is called once per frame //void Update() //{ //} }
posted on 2024-10-29 14:19 zqiang0803 阅读(5) 评论(0) 编辑 收藏 举报