Closed
Description
Method GetBindableChilds from VisualElementExtensions incorrectly handles cases with bindable elements in templates. Suppose there is an empty scene with 1 GameObject called View and 2 attached components (UI Document and TestCaseView). If one would run such scene and click THE BUTTON he would see a "Normal button pressed" in the console, however if he clicks on a pink background there is no "Background button pressed" in the console.
Listing of the files is provided below.
WindowContainer.uxml:
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement name="window-root" style="flex-grow: 1;">
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton command="BackgroundButtonCommand" name="window-closer" class="0; 0; 0;" style="position: absolute; top: 0; left: 0; bottom: 0; right: 0; background-color: rgb(236, 166, 166);" />
<ui:VisualElement name="content-container" contentContainer="true" picking-mode="Ignore" style="flex-grow: 1; align-items: center; justify-content: space-around;" />
</ui:VisualElement>
</ui:UXML>
TestCaseWindow.uxml:
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Template name="WindowContainer" src="project://database/Assets/TestCase/WindowContainer.uxml?fileID=9197481963319205126&guid=54cc8b8584dd8494a83f70ca4058d5b4&type=3#WindowContainer" />
<ui:Instance template="WindowContainer" style="flex-grow: 1;">
<UnityMvvmToolkit.UITK.BindableUIElements.BindableButton command="NormalButtonCommand" text="THE BUTTON" name="ok-button" style="width: 300px; height: 200px; font-size: 50px;" />
</ui:Instance>
</ui:UXML>
TestCaseViewModel.cs:
public class TestCaseViewModel : IBindingContext
{
public ICommand NormalButtonCommand { get; }
public ICommand BackgroundButtonCommand { get; }
public TestCaseViewModel()
{
NormalButtonCommand = new Command(() => Debug.Log("Normal button pressed"));
BackgroundButtonCommand = new Command(() => Debug.Log("Background button pressed"));
}
}
TestCaseView.cs:
public class TestCaseView : DocumentView<TestCaseViewModel>
{
}