using System;
using UniRx;
using UniRx.Triggers;
using UnityEngine;
using UnityEngine.UI;

public class ButtonObjectSwitcher : MonoBehaviour
{
    [SerializeField] private Button growthButton;
    [SerializeField] private GameObject onObject;
    [SerializeField] private GameObject offObject;

    private void Start()
    {
        onObject.SetActive(false);
        offObject.SetActive(true);
        growthButton.OnPointerDownAsObservable()
            .Select(_ => true)
            .Merge(growthButton.OnPointerUpAsObservable().Select(_ => false))
            .Subscribe(x =>
            {
                onObject.SetActive(x);
                offObject.SetActive(!x);
            }).AddTo(this);
    }
}
