45 lines
978 B
C#
45 lines
978 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class SparePartsButton : Button
|
|
{
|
|
private bool onHover,show;
|
|
private float time;
|
|
private Image _image;
|
|
public Image Image { get { if (_image == null) _image = GetComponent<Image>(); return _image; } }
|
|
|
|
protected override void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
public override void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
onHover = true;
|
|
}
|
|
|
|
public override void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
onHover = show = false;
|
|
time = 0;
|
|
PreviewWindow.Preveiw(null);
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if(onHover)
|
|
{
|
|
time += Time.deltaTime;
|
|
if (time > 0.2f)
|
|
{
|
|
if (!show)
|
|
PreviewWindow.Preveiw(Image.sprite);
|
|
show = true;
|
|
}
|
|
}
|
|
}
|
|
}
|