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() //{ //} }
标签:SlideView,AddListener,void,slide,value,Unity,滑动,onValueChanged,sb From: https://www.cnblogs.com/zqiang0803/p/18513016