diff --git a/AudioEvent/Runtime/AudioEvent.cs b/AudioEvent/AudioEvent.cs similarity index 100% rename from AudioEvent/Runtime/AudioEvent.cs rename to AudioEvent/AudioEvent.cs diff --git a/AudioEvent/Runtime/SimpleAudioEvent.cs b/AudioEvent/SimpleAudioEvent.cs similarity index 100% rename from AudioEvent/Runtime/SimpleAudioEvent.cs rename to AudioEvent/SimpleAudioEvent.cs diff --git a/Canvases/Components/ButtonUIComponent.cs b/Canvases/Components/ButtonUIComponent.cs new file mode 100644 index 0000000..d9afcdb --- /dev/null +++ b/Canvases/Components/ButtonUIComponent.cs @@ -0,0 +1,62 @@ +using System; +using Sirenix.OdinInspector; +using UnityEngine; +using UnityEngine.UI; + +namespace Canvases.Components +{ + public class ButtonUIComponent : UISelectableComponentBase + { + public event Action OnClick; + + [Header("Association"), SerializeField, Required] + private Button button; + + [Header("Configuration"), SerializeField] + private ButtonNavigationType buttonNavigationType; + + private enum ButtonNavigationType + { + Forward, + Backward + } + + public Color Color + { + set => button.image.color = value; + } + + public bool Enabled + { + set => button.interactable = value; + } + + public void Select() => button.Select(); + + protected override void SetSelectableGameObject() => Selectable = button; + + private void Start() + { + Debug.Assert(button, $"A {nameof(button)} must be assigned to a {nameof(ButtonUIComponent)}"); + button.onClick.AddListener(OnButtonClicked); + } + + protected override void OnDestroy() + { + button.onClick.RemoveListener(OnButtonClicked); + base.OnDestroy(); + } + + private void OnButtonClicked() + { + // PlayClickedSound(); + OnClick?.Invoke(); + } + + private void OnValidate() + { + if (!button) + button = GetComponent