12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- [RequireComponent(typeof(Slider))]
- public class UISliderScroll : MonoBehaviour
- {
- private Slider slider
- {
- get
- {
- if (this.m_Slider == null)
- {
- this.m_Slider = base.GetComponent<Slider>();
- }
- return this.m_Slider;
- }
- }
- public void SetSliderValue(Vector2 position)
- {
- this.slider.value = ((!this.m_IsXValue) ? position.y : position.x);
- if (this.m_ScrollRect == null)
- {
- return;
- }
- RectTransform component = this.m_ScrollRect.GetComponent<RectTransform>();
- Rect rect = component.rect;
- Rect rect2 = this.m_ScrollRect.content.rect;
- float num;
- if (this.m_IsXValue)
- {
- num = rect2.width - rect.width;
- }
- else
- {
- num = rect2.height - rect.height;
- }
- this.m_SliderObject.SetActive(num > 0f);
- }
- [SerializeField]
- [Tooltip("スクロールの必要がないときに非表示にするゲームオブジェクトの参照")]
- private GameObject m_SliderObject;
- [SerializeField]
- private ScrollRect m_ScrollRect;
- public bool m_IsXValue;
- private Slider m_Slider;
- }
|