# mob-sakai/uieffect architecture

> Architecture diagram of the GitHub repository mob-sakai/uieffect, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mob-sakai/uieffect
- Repository: https://github.com/mob-sakai/uieffect

## Overview

##### Main Components
- Runtime Engine: Represented primarily in Packages/src/Runtime. This includes core classes (e.g., UIEffect.cs, UIEffectBase.cs, UIEffectContext.cs) that handle runtime behaviors for UI effects.
- Editor Extensions: Found in Packages/src/Editor. These components (like UIEffectEditor.cs, UIEffectProjectSettingsEditor.cs, and related assembly definitions) add integration in the Unity editor, enabling customization and configuration.
- Shader and Graphical Assets: Located in Packages/src/Shaders and the extensive TextMesh Pro support in both Assets and Packages/src/Samples. This set includes shader files (e.g., TMP_SDF.shader variants, UIEffect.shader, UIEffect.cginc, etc.) that are essential for the visual effects.
- Presets and Utilities: In packages such as Packages/src/UIEffectPresets and Packages/src/Runtime/Utilities. These provide ready-made effect presets and helper classes (like Logging, ObjectPool, GradientUtil, etc.) to support the functionality of UI effects.
- Demo and Sample Scenes: Present in Assets/Demos and Packages/src/Samples~. These components show how the effects can be applied in Unity scenes and serve as reference integrations.
- Tests: Located under Assets/Tests and possibly integrated with scripts in Packages. These ensure the system integrity (e.g., EditorTests.asmdef) and are important for maintaining quality.
- Unity Project Settings: The standalone ProjectSettings folder and certain runtime settings indicate that there may be integration with Unity’s project-setting mechanisms (such as preloaded UIEffect project settings).

##### Relationships and Interactions
- The Runtime Engine (core UIEffect logic) interacts directly with Unity’s UI system to produce visual effects. It also consumes the Shader assets when rendering these effects.
- The Editor Extensions provide inspectors, custom editors, and project setting windows that wrap around the runtime components for configuration purposes. They “talk” to the runtime layer through shared APIs.
- The Shader and Preset components supply the visual assets and pre-configured effect options that the Runtime Engine can load and apply.
- Demos and Sample Scenes serve as practical examples that instantiate the runtime UI effects, often configured via the Editor Extensions.
- Utilities and internal helper libraries are used throughout both runtime and editor layers, facilitating tasks such as logging, caching, object pooling, and material management.

##### Architectural Patterns and Design Principles
- Modular Separation: The design clearly distinguishes between runtime logic, editor customization, and asset presets. This separation follows modular programming practices in Unity (notably with asmdef files to create separate assemblies).
- Dependency Injection and Single Responsibility: The internal utilities (e.g., Logging, ObjectPool) suggest that components have clearly defined responsibilities, enabling easier debugging and testing.
- MVC/MVVM-Like Pattern: While not explicitly an MVC framework, the separation of UI rendering (via shaders and visual assets) from configuration (editor scripts) implies a clean separation similar to modern UI design principles.
- Extensibility: The extensive presets and the clear separation between core runtime and editor components indicate that designers or developers can extend or modify behavior without altering the core engine.

##### Relevant Technologies, Frameworks, and Libraries
- Unity Engine: The primary platform, with native support for C# scripting, asset management, and scene integration.
- Unity Shader Language (HLSL/Cg): For the shader implementations within the "Shaders" folder.
- TextMeshPro: Evident in the "TextMesh Pro" folders and related shader/material assets, used for text rendering.
- Assembly Definition Files (asmdef): Used to segment the code into Runtime, Editor, and Test assemblies.
- YAML-based configurations and Unity’s ProjectSettings which may influence runtime behaviors.

- “Runtime Engine (Packages/src/Runtime)”
- “Editor Extensions (Packages/src/Editor)”
- “Shaders & Visual Assets (Packages/src/Shaders & Assets/TextMesh Pro)”
- “Presets & Utilities (Packages/src/UIEffectPresets & Packages/src/Runtime/Utilities)”
- “Demo Scenes & Samples (Assets/Demos and Packages/src/Samples~)”
- “Tests (Assets/Tests)”
- “Unity Project Settings (ProjectSettings folder)”
- The runtime components using shader assets.
- The Editor modules configuring and wrapping around the runtime.
- Demo scenes in Assets instantiating and showcasing the runtime features.
- Utility classes supporting both runtime and editor.
- Optionally, include a boundary that shows how the package integrates with the Unity Engine (as an external dependency that provides the underlying platform).

##### Detailing and Clarity
- Be as thorough as possible in labeling each component and its role.

## Diagram (Mermaid)

```mermaid
graph TD
  UE["Unity Engine"]:::external
  UP["Unity Project Settings (ProjectSettings)"]:::settings
  RTE["Runtime Engine (Packages/src/Runtime)"]:::runtime
  ED["Editor Extensions (Packages/src/Editor)"]:::editor
  SH["Shaders & Visual Assets (Packages/src/Shaders & Assets/TextMesh Pro)"]:::assets
  PS["Presets (Packages/src/UIEffectPresets)"]:::assets
  UT["Utilities (Packages/src/Runtime/Utilities)"]:::assets
  DM["Demo Scenes (Assets/Demos)"]:::demos
  SP["Samples (Packages/src/Samples~)"]:::demos
  TS["Tests (Assets/Tests)"]:::tests

  %% External Unity Engine interactions
  UE -->|"supports"| RTE
  UE -->|"supports"| ED
  UE -->|"configures"| UP

  %% Editor and Runtime relationship
  ED -->|"configures"| RTE

  %% Runtime dependencies on assets and utilities
  RTE -->|"renders with"| SH
  RTE -->|"loads"| PS
  RTE -->|"utilizes"| UT

  %% Utilities aiding Editor as well
  UT -->|"supports"| ED

  %% Demo and Sample scenes instantiating runtime effects
  DM -->|"instantiates"| RTE
  SP -->|"instantiates"| RTE

  %% Tests covering both Runtime and Editor components
  TS -->|"validates"| RTE
  TS -->|"validates"| ED

  %% Click Events
  click RTE "https://github.com/mob-sakai/uieffect/tree/main/Packages/src/Runtime"
  click ED "https://github.com/mob-sakai/uieffect/tree/main/Packages/src/Editor"
  click SH "https://github.com/mob-sakai/uieffect/tree/main/Packages/src/Shaders"
  click SH "https://github.com/mob-sakai/uieffect/tree/main/Assets/TextMesh Pro/Shaders"
  click PS "https://github.com/mob-sakai/uieffect/tree/main/Packages/src/UIEffectPresets"
  click UT "https://github.com/mob-sakai/uieffect/tree/main/Packages/src/Runtime/Utilities"
  click DM "https://github.com/mob-sakai/uieffect/tree/main/Assets/Demos"
  click SP "https://github.com/mob-sakai/uieffect/tree/main/Packages/src/Samples~"
  click TS "https://github.com/mob-sakai/uieffect/tree/main/Assets/Tests"
  click UP "https://github.com/mob-sakai/uieffect/tree/main/ProjectSettings"

  %% Styling classes
  class UE external
  class RTE runtime
  class ED editor
  class SH,PS,UT assets
  class DM,SP demos
  class TS tests
  class UP settings

  %% Class Definitions
  classDef external fill:#add8e6,stroke:#333,stroke-width:2px;
  classDef runtime fill:#98fb98,stroke:#333,stroke-width:2px;
  classDef editor fill:#90ee90,stroke:#333,stroke-width:2px;
  classDef assets fill:#ffeb99,stroke:#333,stroke-width:2px;
  classDef demos fill:#ffd700,stroke:#333,stroke-width:2px;
  classDef tests fill:#ffb6c1,stroke:#333,stroke-width:2px;
  classDef settings fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
