26 lines
		
	
	
		
			740 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			740 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using KBCore.Refs;
 | |
| using UnityEngine;
 | |
| 
 | |
| 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;
 | |
| 
 | |
|         private void Awake()
 | |
|         {
 | |
|             if (attachedButton != null)
 | |
|                 Apply(attachedButton);
 | |
|         }
 | |
| 
 | |
|         private void OnValidate()
 | |
|         {
 | |
|             this.ValidateRefs();
 | |
|             if (attachedButton == null && TryGetComponent(out ButtonSettings settings))
 | |
|                 settings.Refresh();
 | |
|         }
 | |
| 
 | |
|         public virtual void Apply(BaseButton button) => button.AddOrOverrideSetting(this);
 | |
|     }
 | |
| } |