using UnityEngine;

namespace HyperstoneSdk
{
    class HyperstoneObjectEnable : MonoBehaviour
    {
        [SerializeField] private string ConfigKey;

        private void Awake()
        {
            Hyperstone.WatchConfig(OnConfigChanged);
        }

        private void OnConfigChanged(HyperstoneConfig config)
        {
            gameObject.SetActive(config.GetBoolOrDefault(ConfigKey, false));
        }

        private void OnDestroy()
        {
            Hyperstone.UnwatchConfig(OnConfigChanged);
        }
    }
}
