Hi,
I was trying to learn UI Toolkit with UI Toolkit Unity Royale Runtime Demo
I saw something like this: someButton.RegisterCallback(ev => DoSomething());
but I didn’t saw it unregister the callback somewhere
However to my understanding usually we should unregister our callbacks.
I was wondering if I misunderstand something?
It would be awesome if someone could help explain!
some codes from the demo project:
void OnEnable()
{
// Retrieving interesting elements to:
// 1- set values
// 2- assign behaviors
// 3- animate!
var rootVisualElement = GetComponent<UIDocument>().rootVisualElement;
matchOverLabel = rootVisualElement.Q<Label>("match-over-label");
winnerIsLabel = rootVisualElement.Q<Label>("winner-is-label");
winnerTeamNameLabel = rootVisualElement.Q<Label>("winner-label");
mainMenuButton = rootVisualElement.Q<Button>("main-menu-button");
// Attaching callback to the button.
mainMenuButton.RegisterCallback<ClickEvent>(ev => OnMainMenuButton());
}