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

public class PromoteGrowthButton : 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))
            .Pairwise()
            .Subscribe(x =>
            {
                onObject.SetActive(x.Current);
                offObject.SetActive(!x.Current);
            }).AddTo(this);
    }
}
