First commit for private source control. Older commits available on Github.
This commit is contained in:
50
Assets/Scripts/UI/Codex/CodexCategoryButton.cs
Normal file
50
Assets/Scripts/UI/Codex/CodexCategoryButton.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace BriarQueen.UI.Codex
|
||||
{
|
||||
public class CodexCategoryButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Button _button;
|
||||
|
||||
[SerializeField]
|
||||
private Image _selectedBackground;
|
||||
|
||||
public CodexType Category { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_button != null)
|
||||
_button.onClick.AddListener(HandleClicked);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_button != null)
|
||||
_button.onClick.RemoveListener(HandleClicked);
|
||||
}
|
||||
|
||||
public event Action<CodexType> OnCategoryClicked;
|
||||
|
||||
public void Initialize(CodexType category)
|
||||
{
|
||||
Category = category;
|
||||
|
||||
SetSelected(false);
|
||||
}
|
||||
|
||||
public void SetSelected(bool selected)
|
||||
{
|
||||
if (_selectedBackground != null)
|
||||
_selectedBackground.enabled = selected;
|
||||
}
|
||||
|
||||
private void HandleClicked()
|
||||
{
|
||||
OnCategoryClicked?.Invoke(Category);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user