44 lines
781 B
C#
44 lines
781 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class CosmeticLockedHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
|
|
{
|
|
public GameObject image;
|
|
|
|
private AudioSource audioSource;
|
|
|
|
public AudioClip[] audioclips;
|
|
|
|
private void Start()
|
|
{
|
|
audioSource = GetComponent<AudioSource>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
private void playHoverSound()
|
|
{
|
|
audioSource.clip = audioclips[0];
|
|
audioSource.Play();
|
|
}
|
|
|
|
public void click()
|
|
{
|
|
audioSource.clip = audioclips[1];
|
|
audioSource.Play();
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
image.gameObject.SetActive(value: true);
|
|
playHoverSound();
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
image.gameObject.SetActive(value: false);
|
|
}
|
|
}
|