ict.shenzhi/Assets/ZHYscrip/scrip/scrollMove.cs

45 lines
988 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class scrollMove : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
public bool inside=false;
public GameObject Scroll;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (inside)
{
if (Input.mouseScrollDelta.y != 0)
{
Debug.Log(Input.mouseScrollDelta.y);
Scroll.GetComponent<Scrollbar>().value += Input.mouseScrollDelta.y * 0.01f;
}
}
}
public void OnPointerClick(PointerEventData eventData)
{
}
public void OnPointerEnter(PointerEventData eventData)
{
inside = true;
}
public void OnPointerExit(PointerEventData eventData)
{
inside = false;
}
}