feat: обновлены цвета элементов интерфейса и добавлено событие фокуса для кнопки

This commit is contained in:
yastreb 2026-04-29 14:20:41 +03:00
parent 6ceafddd00
commit e2feadc091
5 changed files with 3988 additions and 129 deletions

View File

@ -74,8 +74,8 @@ MonoBehaviour:
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
rgba: 4288012019
m_fontColor: {r: 0.95294124, g: 0.8705883, b: 0.58431375, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:

View File

@ -195,7 +195,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0.6785973, b: 0.9433962, a: 1}
m_Color: {r: 1, g: 0.8470589, b: 0.46274513, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1

File diff suppressed because it is too large Load Diff

View File

@ -4,19 +4,21 @@
public class UIButtonHighlight : MonoBehaviour
{
public GameObject[] highlightObjects; // Ýëĺěĺíňű (đŕěęč/čęîíęč), ęîňîđűě ěĺí˙ĺě öâĺň
public GameObject[] highlightObjects; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
public Color normalColor = Color.white; // Öâĺň ôîíŕ ęíîďęč
public Color highlightedColor = Color.yellow; // Öâĺň ôîíŕ ďđč âűäĺëĺíčč
public Color normalColor = Color.white; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Color highlightedColor = Color.yellow; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Color highlightOnColor = Color.yellow; // Öâĺň highlight-îáúĺęňîâ ęîăäŕ âűáđŕíŕ
public Color highlightOffColor = Color.white; // Öâĺň highlight-îáúĺęňîâ ęîăäŕ íĺ âűáđŕíŕ
public Color highlightOnColor = Color.yellow; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD> highlight-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public Color highlightOffColor = Color.white; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD> highlight-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private Image buttonImage;
private TextMeshProUGUI buttonText;
private Color originalTextColor;
public Color disabledTextColor = Color.gray;
public System.Action onFocused; // вызывается когда кнопка получает фокус
void Awake()
{
buttonImage = GetComponent<Image>();
@ -30,22 +32,22 @@ void Awake()
public void SetHighlighted(bool state)
{
// Ěĺí˙ĺě öâĺň ôîíŕ ęíîďęč
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (buttonImage != null)
buttonImage.color = state ? highlightedColor : normalColor;
// Ěĺí˙ĺě öâĺň ňĺęńňŕ
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (buttonText != null)
buttonText.color = state ? originalTextColor : disabledTextColor;
// Ěĺí˙ĺě öâĺň âńĺő highlight-îáúĺęňîâ
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> highlight-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (highlightObjects != null)
{
foreach (var obj in highlightObjects)
{
if (!obj) continue;
// 1. Čůĺě Image
// 1. <EFBFBD><EFBFBD><EFBFBD><EFBFBD> Image
var img = obj.GetComponent<Image>();
if (img != null)
{
@ -53,7 +55,7 @@ public void SetHighlighted(bool state)
continue;
}
// 2. Čëč SpriteRenderer
// 2. <EFBFBD><EFBFBD><EFBFBD> SpriteRenderer
var sr = obj.GetComponent<SpriteRenderer>();
if (sr != null)
{
@ -62,5 +64,7 @@ public void SetHighlighted(bool state)
}
}
}
if (state) onFocused?.Invoke();
}
}

File diff suppressed because one or more lines are too long