Title Screen
Polished UI for the title screen Added login, registration and session management to CultClient Connected title screen to CultClient login and registration
This commit is contained in:
parent
28c06289bf
commit
95947355c2
37 changed files with 4639 additions and 2433 deletions
|
|
@ -6,96 +6,7 @@ using UnityEngine;
|
|||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TabButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
public class TabButton : FlatButton
|
||||
{
|
||||
public event Action<TabButton> OnClick;
|
||||
public float StateDamping;
|
||||
public RectTransform Tab;
|
||||
public Image Fill;
|
||||
public Image Outline;
|
||||
public TextMeshProUGUI Label;
|
||||
public VerticalLayoutGroup LabelLayout;
|
||||
public TabButtonState CurrentState = TabButtonState.Unselected;
|
||||
|
||||
public TabButtonAppearance UnselectedAppearance;
|
||||
public TabButtonAppearance SelectedAppearance;
|
||||
public TabButtonAppearance HoverAppearance;
|
||||
public TabButtonAppearance ClickAppearance;
|
||||
|
||||
private RectOffset _defaultPadding;
|
||||
private float _currentPadding;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_defaultPadding = LabelLayout.padding;
|
||||
_currentPadding = _defaultPadding.left;
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState == TabButtonState.Unselected)
|
||||
CurrentState = TabButtonState.Hover;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState == TabButtonState.Hover)
|
||||
CurrentState = TabButtonState.Unselected;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState != TabButtonState.Selected)
|
||||
{
|
||||
Fill.color = ClickAppearance.FillColor;
|
||||
Outline.color = ClickAppearance.OutlineColor;
|
||||
OnClick?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
TabButtonAppearance appearance;
|
||||
switch (CurrentState)
|
||||
{
|
||||
case TabButtonState.Unselected:
|
||||
appearance = UnselectedAppearance;
|
||||
break;
|
||||
case TabButtonState.Selected:
|
||||
appearance = SelectedAppearance;
|
||||
break;
|
||||
case TabButtonState.Hover:
|
||||
appearance = HoverAppearance;
|
||||
break;
|
||||
default:
|
||||
appearance = new TabButtonAppearance();
|
||||
break;
|
||||
}
|
||||
|
||||
Fill.color = Color.Lerp(Fill.color, appearance.FillColor, StateDamping * Time.deltaTime);
|
||||
Outline.color = Color.Lerp(Outline.color, appearance.OutlineColor, StateDamping * Time.deltaTime);
|
||||
_currentPadding = Mathf.Lerp(_currentPadding, appearance.LayoutPadding, StateDamping * Time.deltaTime);
|
||||
LabelLayout.padding = new RectOffset
|
||||
{
|
||||
bottom = _defaultPadding.bottom,
|
||||
top = _defaultPadding.top,
|
||||
left = (int) _currentPadding,
|
||||
right = (int) _currentPadding
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum TabButtonState
|
||||
{
|
||||
Unselected,
|
||||
Selected,
|
||||
Hover
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct TabButtonAppearance
|
||||
{
|
||||
public Color FillColor;
|
||||
public Color OutlineColor;
|
||||
public int LayoutPadding;
|
||||
}
|
||||
Loading…
Reference in a new issue