Callback triggered when the target element is clicked.
Encapsulates a method that has no parameters and does not return a value.
using UnityEngine; using UnityEditor; using UnityEngine.UIElements;
public class ButtonExample : EditorWindow { [MenuItem("Window/Button Example")] public static void ShowExample() { GetWindow<ButtonExample>(); }
void CreateGUI() { var button = new Button { text = "Click me" }; button.clicked += OnClick;
rootVisualElement.Add(button); }
void OnClick() { Debug.Log("Clicked!"); } }