How To Check a VisualElement
using SoyWar.UIToolkit;
using SoyWar.UIToolkit.Elements;
using UnityEngine;
using UnityEngine.UIElements;
public class MyComponent : MonoBehaviour
{
// Use UIDocument
[SerializeField] private UIDocument _element;
// Or UI Toolkit Component
[SerializeField] private VisualElementComponent _element;
// Or any UI Element
private VisualElement _element;
public void Method(VisualElement target)
{
// Create a Selector via the Selector Builder
Selector selector = Selector.Builder(className: "element").Build();
// Or via the Selector Parser
Selector selector = Selector.Parse(".element");
// Check the presence of a VisualElement that matches with the selector
bool check = selector.Exists(_element);
// Check if the current VisualElement matches with the selector
bool check = selector.Match(_element, target);
}
}