How fuqunaga/rosettaui works
Main Architectural Components
• Unity Integration Layer – This sits at the very bottom. It includes all the native Unity systems such as input (using either the new Input System or Legacy Input), scene management, and prefab configuration. (E.g., the RosettaUIRoot prefabs found in Assets or in the Packages/RosettaUI – UIToolkit folder.)
• Runtime: Contains the core UI elements (Elements, Binder components, Builder components, Clipboard functionality, IL2CPP utilities, Reactive/subscription mechanisms, UI “glue” between data and visual elements, and various helper utilities).
• Editor: Provides design-time features (Inspector extensions, Editor windows, and other developer tooling) to assist users when building UIs in the Unity Editor.
• UI Toolkit and UGUI Specific Folders – Notice that there are separate packages for “rosettaui.ugui” (UGUI-based implementation) and “rosettaui.uitoolkit” (UI Toolkit–based implementation). They encapsulate how the element hierarchies are rendered on the chosen UI framework.
• UI Building Abstraction – The code samples show that developers write code to create an “Element” tree using a fluent API (e.g., UI.Window, UI.Page, UI.Field, UI.Slider, etc.). This “builder” layer abstracts away the low-level UI system and converts the Element tree into real, rendered objects.
• Binding and Reactive System – The Binder folders and Reactive components suggest that the library provides data binding, value observation, and event propagation mechanisms for connecting UI with underlying data models.
• Testing and Examples – The Assets folder has Example scenes, runtime code sample files (like ExampleSimple.cs) and editor tests showing how the library is used and verified, which is helpful for understanding component interaction.
• External Dependencies/Guidelines – The README shows integration with scoped registries, Input System recommendations, and the UI library selection. Represent these external configuration/integration points, such as Unity’s Package Manager, the Input System, and even third‐party JSON utilities (e.g., the MiniJson code used in the Clipboard functions).
Relationships and Data Flows
• The developer code (for instance, in ExampleSimple.cs) calls RosettaUIRoot.Build with an Element tree as parameter. This establishes the high-level “invocation” pattern.
• The UI Builder layer converts your fluent “UI” calls into a hierarchy of Element objects. These objects are then processed by binding components (Binder) which connect data (from object properties, fields, etc.) to the visual representation.
• The reactive system is notified of any UI changes, and events propagate back to modify bound data.
• In Editor mode, specialized Editor scripts (in the Editor directories) offer design time feedback and additional configuration.
• There is a clear separation between runtime UI rendering (in the Runtime directories) and editor functionality (in Editor directories).
Architectural Patterns & Design Principles
• Separation of Concerns – The system is divided into packages handling UI creation (builders), UI rendering (elements and runtime systems), data binding (Binder), and editor integration.
• Modular & Pluggable Architecture – Different UI frameworks (UI Toolkit and UGUI) are clearly separated in their respective packages. Each has its own set of prefabs, scripts, and configuration.
• Declarative UI Construction – Using a builder pattern (as demonstrated in the code sample) and reactive bindings to keep UI code modular and testable.
• Extensibility – Several directories (like Utility, Builder, and Reactive) show extensibility points and helper functions that allow developers to create custom behavior or extend the basic functionality.