I have a custom control with two properties, for example:
[UxmlElement("TestCustomControl")]
public partial class TestCustomControl : VisualElement
{
[UxmlAttribute]
public string MyString { get; set; } = MYSTRING_DEFAULT_VALUE;
[UxmlAttribute]
public int MyInt { get; set; } = MYINT_DEFAULT_VALUE;
// etc ...
and I have code in a method that modifies those values, for example:
private void SetConfiguration2()
{
Debug.Log("Setting configuration 2");
MyString = "Config2 string";
MyInt = 2;
}
I see the values are properly update in UIBuilder Inspector, for example:
However, the UXML file does Not reflect those new values, for example:

I am looking for a way to make those properties to be serialized to the UXML file whenever their values change in code, for example:
So my questions are:
- How can I make the properties to serialize (preferrable immediately) to the UXML when their values change programmatically?
- If not possible ^ Can I at least mark them as “dirty” or mark the whole UXML file marked as “changes made” so that the user saves it? Something like this?