Clickable
Constructor.
Read time 2 minutesLast updated 7 days ago
Definition
- Type: Constructor
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
Clickable(Action, long, long)
Constructor.
public Clickable(Action handler, long delay, long interval)
Parameters
Examples
using UnityEditor;using UnityEngine;using UnityEngine.UIElements;public class ClickableEditorWindow : EditorWindow{ [MenuItem("Window/UI Toolkit/Clickable Example")] public static void ShowWindow() { var window = GetWindow<ClickableEditorWindow>(); window.titleContent = new GUIContent("Clickable Example"); } public void CreateGUI() { var clickableElement = new VisualElement { style = { width = 200, height = 40, backgroundColor = new Color(0.2f, 0.6f, 0.8f, 1), justifyContent = Justify.Center, alignItems = Align.Center, } }; clickableElement.Add(new Label("Click Me")); clickableElement.AddManipulator(new Clickable(() => { Debug.Log("Element clicked!"); })); rootVisualElement.Add(clickableElement); }}
Clickable(Action<EventBase>)
Constructor.
public Clickable(Action<EventBase> handler)
Parameters
Examples
using UnityEditor;using UnityEngine;using UnityEngine.UIElements;public class ClickableEditorWindow : EditorWindow{ [MenuItem("Window/UI Toolkit/Clickable Example")] public static void ShowWindow() { var window = GetWindow<ClickableEditorWindow>(); window.titleContent = new GUIContent("Clickable Example"); } public void CreateGUI() { var clickableElement = new VisualElement { style = { width = 200, height = 40, backgroundColor = new Color(0.2f, 0.6f, 0.8f, 1), justifyContent = Justify.Center, alignItems = Align.Center, } }; clickableElement.Add(new Label("Click Me")); clickableElement.AddManipulator(new Clickable(() => { Debug.Log("Element clicked!"); })); rootVisualElement.Add(clickableElement); }}
Clickable(Action)
Constructor.
public Clickable(Action handler)
Parameters
Examples
using UnityEditor;using UnityEngine;using UnityEngine.UIElements;public class ClickableEditorWindow : EditorWindow{ [MenuItem("Window/UI Toolkit/Clickable Example")] public static void ShowWindow() { var window = GetWindow<ClickableEditorWindow>(); window.titleContent = new GUIContent("Clickable Example"); } public void CreateGUI() { var clickableElement = new VisualElement { style = { width = 200, height = 40, backgroundColor = new Color(0.2f, 0.6f, 0.8f, 1), justifyContent = Justify.Center, alignItems = Align.Center, } }; clickableElement.Add(new Label("Click Me")); clickableElement.AddManipulator(new Clickable(() => { Debug.Log("Element clicked!"); })); rootVisualElement.Add(clickableElement); }}