28 lines
786 B
C#
28 lines
786 B
C#
using KBCore.Refs;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace NEG.UI.UnityUi.Buttons.Settings
|
|
{
|
|
public abstract class SettingData : MonoBehaviour
|
|
{
|
|
[field: SerializeField] public string Key { get; private set; }
|
|
[SerializeField, Self(Flag.Optional)] private BaseButton attachedButton;
|
|
|
|
public virtual void Apply(BaseButton button) => button.AddOrOverrideSetting(this);
|
|
|
|
private void Awake()
|
|
{
|
|
if(attachedButton != null)
|
|
Apply(attachedButton);
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
this.ValidateRefs();
|
|
if (attachedButton == null && TryGetComponent(out ButtonSettings settings))
|
|
settings.Refresh();
|
|
}
|
|
}
|
|
} |