This commit is contained in:
CortexCore
2023-10-04 16:50:27 +08:00
parent 947e52e748
commit 5cd094ed9a
263 changed files with 144068 additions and 66 deletions

View File

@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace Lightbug.CharacterControllerPro.Demo
{
public class MenuButton : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
[SerializeField]
string sceneName = "";
[SerializeField]
Color highlightColor = Color.green;
[SerializeField]
float lerpSpeed = 5f;
Color normalColor;
Image image = null;
bool enter = false;
void Awake()
{
image = GetComponent<Image>();
if (image == null)
{
enabled = false;
return;
}
normalColor = image.color;
}
void Update()
{
image.color = Color.Lerp(image.color, enter ? highlightColor : normalColor, lerpSpeed * Time.deltaTime);
}
public void OnPointerClick(PointerEventData eventData)
{
MainMenuManager.Instance.GoToScene(sceneName);
}
public void OnPointerEnter(PointerEventData eventData)
{
enter = true;
}
public void OnPointerExit(PointerEventData eventData)
{
enter = false;
}
}
}