using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using NRKernal.Persistence;

public class HideButtons : MonoBehaviour
{

   public void ToggleAllCanvasesVisibility()
    {
        // 获取场景中所有的GameObject
        GameObject[] allObjects = FindObjectsOfType<GameObject>();

        // 对每个名为"AnchorItem"的GameObject，切换其Canvas的可见性
        foreach (GameObject obj in allObjects)
        {
            if (obj.name.Contains("AnchorItem"))
            {
                // 获取AnchorItem脚本
                AnchorItem anchorItem = obj.GetComponent<AnchorItem>();

                // 如果GameObject上有AnchorItem脚本，切换其Canvas的可见性
                if (anchorItem != null)
                {
                    anchorItem.ToggleCanvasVisibility();
                }
            }
        }
    }
}
