Generated Code

Each generated script will contain a single class whose name is derived from the .uxml file name. The file name is converted to a valid C# class name using PascalCase formatting. Invalid characters are removed.

For the .uxml file my-settings-panel.uxml will be created MySettingsPanel.generated.cs script with class name: MySettingsPanel.

You can then use this class as a partial or base class for your UI logic, with all named elements available as strongly-typed fields or properties.

Generated class contains:

  • An empty constructor and constructor that takes a VisualElement or UIDocument and calls FindFields(...)

  • One public property for each element in the .uxml file with a name attribute

  • A FindFields(...) method that automatically maps those names using Q<>()

You are free to:

  • Change the namespaces

  • Rename the generated classes

  • Move the files to a different folders

AutoFields will continue to detect and update the class correctly, as long as the original generated fields section markers are preserved.