Super Sexy Properties Panel
Properties panel now allows nested lists with foldouts, item selection and click callbacks Properties Panel UI has a new look Refactored lambdas in control module code into methods for readability
This commit is contained in:
parent
68473a84ab
commit
50a8059ed4
43 changed files with 894 additions and 916 deletions
68
Assets/Scripts/UI/FlatFlatButton.cs
Normal file
68
Assets/Scripts/UI/FlatFlatButton.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FlatFlatButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
{
|
||||
public event Action OnClick;
|
||||
public float StateDamping;
|
||||
// public RectTransform Tab;
|
||||
public Image Fill;
|
||||
public FlatButtonState CurrentState = FlatButtonState.Unselected;
|
||||
public bool DisableClickWhenSelected = true;
|
||||
|
||||
public Color UnselectedColor;
|
||||
public Color SelectedColor;
|
||||
public Color HoverColor;
|
||||
public Color ClickColor;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (OnClick != null && CurrentState == FlatButtonState.Unselected)
|
||||
CurrentState = FlatButtonState.Hover;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState == FlatButtonState.Hover)
|
||||
CurrentState = FlatButtonState.Unselected;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (!DisableClickWhenSelected || CurrentState != FlatButtonState.Selected)
|
||||
{
|
||||
if (OnClick != null)
|
||||
{
|
||||
Fill.color = ClickColor;
|
||||
OnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Color appearance;
|
||||
switch (CurrentState)
|
||||
{
|
||||
case FlatButtonState.Unselected:
|
||||
appearance = UnselectedColor;
|
||||
break;
|
||||
case FlatButtonState.Selected:
|
||||
appearance = SelectedColor;
|
||||
break;
|
||||
case FlatButtonState.Hover:
|
||||
appearance = HoverColor;
|
||||
break;
|
||||
default:
|
||||
appearance = Color.white;
|
||||
break;
|
||||
}
|
||||
|
||||
Fill.color = Color.Lerp(Fill.color, appearance, StateDamping * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue