Answer the question
In order to leave comments, you need to log in
MouseDown and MouseUp events for button in UI Toolkit?
I’ll immediately note that the button was created not in Canvas, but through UI Builder.
I figured out the lesson how to catch a button click:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class UIButtons : MonoBehaviour
{
public Button delete;
// Start is called before the first frame update
void Start()
{
var root = GetComponent<UIDocument>().rootVisualElement;
delete = root.Q<Button>("Delete");
delete.clicked += Clicked;
}
// Update is called once per frame
void Clicked()
{
Debug.Log("CLICKED");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question