Thanks for the update. I think I might try and make a smaller standalone example to duplicate the issue. Currently I have a base class like this for my datasource.
public class ViewModelBase : IDataSourceViewHashProvider, INotifyBindablePropertyChanged
{
private long m_ViewVersion;
public event EventHandler<BindablePropertyChangedEventArgs> propertyChanged;
public void Publish()
{
++m_ViewVersion;
}
public long GetViewHashCode()
{
return m_ViewVersion;
}
protected void Notify([CallerMemberName] string property = "")
{
propertyChanged?.Invoke(this, new BindablePropertyChangedEventArgs(property));
Publish(); // TODO: CHECK
}
}
The data source with the title issue looks like this.
public class CardSetVM : ViewModelBase
{
private string title;
[CreateProperty]
public string Title
{
get => title;
set
{
if (title == value)
{
return;
}
title = value;
Notify();
}
}
}
I have a uxml file called CardSetView.uxml that is using the above as the datasource. This binding works fine when attached to a UIDocument e.g. setting the title in code will update the UI.
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<engine:Template name="CardView" src="project://database/Assets/Poker/Samples/HandSample/UI/CardView.uxml?fileID=9197481963319205126&guid=2f1254b93f1eb7e40b1056f03b57afa5&type=3#CardView" />
<engine:VisualElement data-source-type="KiwiGameDev.Poker.Sample.HandSample.CardSetVM, KiwiGameDev.Poker.Sample.HandSample" style="flex-grow: 1; flex-direction: column; background-color: rgb(36, 36, 36);">
<engine:VisualElement name="Horizontal" style="flex-grow: 1; flex-direction: row; height: auto; max-height: 32px;">
<engine:Label text="Title" name="TitleLabel" style="color: rgb(255, 255, 255); text-overflow: clip; white-space: pre; -unity-text-align: middle-left;">
<Bindings>
<engine:DataBinding property="text" data-source-path="Title" binding-mode="ToTarget" update-trigger="EveryUpdate" />
</Bindings>
</engine:Label>
<engine:Button text="Clear" name="ClearButton" style="align-self: center; visibility: visible; display: flex; width: 63px;">
<KiwiGameDev.MVVM.Core.ClickEventElement data-source-path="ClearCommand" />
<Bindings>
<engine:DataBinding property="style.display" update-trigger="EveryUpdate" data-source-path="ClearButtonDisplayStyle" binding-mode="ToTarget" />
</Bindings>
</engine:Button>
<engine:VisualElement name="WinnerIcon" enabled="true" style="flex-grow: 1; width: 24px; height: 24px; background-image: url("project://database/Assets/Poker/Samples/HandSample/Sprites/trophy.png?fileID=21300000&guid=8ef6f679daff94a458fcbd43d9aefd80&type=3#trophy"); max-width: 24px; justify-content: space-around; align-items: stretch; align-self: center; display: flex; visibility: visible;">
<Bindings>
<engine:DataBinding property="style.visibility" data-source-path="Winner" binding-mode="ToTarget" update-trigger="EveryUpdate" />
</Bindings>
</engine:VisualElement>
<engine:Label text="Title" name="TitleLabel" style="color: rgb(255, 255, 255); text-overflow: clip; white-space: pre; -unity-text-align: middle-left;">
<Bindings>
<engine:DataBinding property="text" data-source-path="Title" binding-mode="ToTarget" update-trigger="OnSourceChanged" />
</Bindings>
</engine:Label>
</engine:VisualElement>
<KiwiGameDev.MVVM.Core.FrameElement data-source-path="Cards" style="flex-direction: row; align-self: stretch; justify-content: flex-start; align-items: center;">
<engine:Instance template="CardView" />
<engine:Instance template="CardView" />
<engine:Instance template="CardView" />
<engine:Instance template="CardView" />
<engine:Instance template="CardView" />
</KiwiGameDev.MVVM.Core.FrameElement>
</engine:VisualElement>
<KiwiGameDev.MVVM.Core.ClearDataSourcePathElement />
</engine:UXML>
However, I have another uxml file below that includes CardSetView which doesn’t work.
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<engine:Template name="CardSetView" src="project://database/Assets/Poker/Samples/HandSample/UI/CardSetView.uxml?fileID=9197481963319205126&guid=d87691ad24eb67c46bcb3cc7d8ab7ac8&type=3#CardSetView" />
<engine:VisualElement data-source-type="KiwiGameDev.Poker.Sample.HandSample.HandSampleVM, KiwiGameDev.Poker.Sample.HandSample" style="flex-grow: 1; background-color: rgb(36, 36, 36);">
<engine:Label text="Label" style="color: rgb(255, 255, 255);">
<Bindings>
<engine:DataBinding property="text" data-source-path="Title" binding-mode="ToTarget" />
</Bindings>
</engine:Label>
<engine:Instance template="CardSetView" name="SpadesCards" data-source-path="SpadesCards" />
<engine:Instance template="CardSetView" name="DiamondsCards" data-source-path="DiamondsCards" />
<engine:Instance template="CardSetView" name="ClubsCards" data-source-path="ClubsCards" />
<engine:Instance template="CardSetView" name="HeartsCards" data-source-path="HeartsCards" />
<engine:VisualElement style="flex-grow: 1; flex-direction: row; justify-content: space-between;">
<engine:Instance template="CardSetView" name="JockerCards" data-source-path="JockerCards" />
<engine:Instance template="CardSetView" name="Player1Cards" data-source-path="Player1Cards" />
<engine:Instance template="CardSetView" name="Player2Cards" data-source-path="Player2Cards" />
<engine:Instance template="CardSetView" name="Player3Cards" data-source-path="Player3Cards" />
</engine:VisualElement>
</engine:VisualElement>
</engine:UXML>
The above does seem to have the correct bindings e.g. I can see the title that is set on load. EveryUpdate also works but OnSourceChanged doesn’t until I directly set the data source and path for some reason. I’m also using Unity 6000.0.3f1.