using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using HeathenEngineering;

public class SettingsButton : MonoBehaviour
{
    [SerializeField] private Toggle toggle;

    [SerializeField] private BoolVariable value;

    private void Awake() => toggle.onValueChanged.AddListener(OnValueChange);

    private void OnEnable() => toggle.isOn = value.Value;

    private void OnDestroy() => toggle.onValueChanged.RemoveListener(OnValueChange);

    public void OnValueChange(bool toggleValue) => value.Value = toggleValue;
}
