Aetheria/Assets/Scripts/UI/TextButton.cs
Reinier Vens b6828a975a Save/Load and Main Menu Submenus
Redid all of the property panel UI prefabs (oof)
Implemented saving and loading of the game state
Moved sector generation to sector constructor (along with loading from save file)
Entity settings now separate from player settings
Player settings (incl. saved run) now statically accessible from game manager
Added animations and submenus to the main menu
Unified main menu settings and properties panel styles for prefab reusability
2021-03-14 03:56:49 +00:00

35 lines
889 B
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using static Unity.Mathematics.math;
public class TextButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public Button Button;
public TextMeshProUGUI Label;
public float AnimationDuration;
public float HoverSpacing;
private float _lerp;
private bool _hovering;
// Update is called once per frame
void Update()
{
_lerp = saturate(_lerp + Time.deltaTime / AnimationDuration * (Button.interactable && _hovering ? 1 : -1));
Label.characterSpacing = HoverSpacing * _lerp;
}
public void OnPointerEnter(PointerEventData eventData)
{
_hovering = true;
}
public void OnPointerExit(PointerEventData eventData)
{
_hovering = false;
}
}