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


namespace SimplifyXR
{
    public class NavButton : MonoBehaviour
    {
        public Image icon;
        public TextMeshProUGUI label;
        public Image anchoredImage;

        bool anchored;

        public void UpdateNavItemPanelAnchoredState(bool anchor)
        {
            anchoredImage.gameObject.SetActive(!anchor);
            anchoredImage.enabled = !anchor;
            anchored = anchor;
        }

        public void UpdateButtonInfo(PanelReference reference)
        {
            icon.sprite = reference.buttonIcon;
            label.text = reference.buttonLabel;

            reference.panelButton.gameObject.name = reference.buttonLabel + " Button";

            if (reference.referenceType == ReferenceType.byAsset) reference.panelButton.interactable = reference.panelObject;
            if (reference.referenceType == ReferenceType.bySceneOrModule) reference.panelButton.interactable = reference.scene;

#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(reference.panelButton);
            UnityEditor.EditorUtility.SetDirty(icon);
            UnityEditor.EditorUtility.SetDirty(label);
#endif 
        }
    }
}

