using System.Collections;
using UnityEngine;

public class ConjureUIElement : MonoBehaviour
{
    public CanvasGroup canvasGroup;
    public bool visible;

    protected virtual void Awake()
    {
        canvasGroup = GetComponent<CanvasGroup>();
        if (canvasGroup == null) { canvasGroup = this.gameObject.AddComponent<CanvasGroup>(); }

        if (canvasGroup.alpha > 0f) { visible = true; }
    }

    public virtual void SetVisible(bool yes)
    {
        if (visible == yes) { return; }

        visible = yes;
        canvasGroup.interactable = yes;
        canvasGroup.blocksRaycasts = yes;

        canvasGroup.alpha = (yes) ? 1f : 0f;
    }
}