# lufias-69/helper-unity architecture

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

- Interactive diagram: https://gitdiagram.com/lufias-69/helper-unity
- Repository: https://github.com/lufias-69/helper-unity

## Overview

##### Project Type and Purpose
- This is a Unity Editor extension package designed to streamline development for Unity developers. It provides custom attributes for better in-inspector UI (e.g., ButtonLUFI, ReadOnlyLUFI, ShowIf), additional editor tools (asset management, folder management, missing script removal, package management), tweening functionalities, general utilities (extension methods, saving system, pooling), and some web integration (downloaders).
- The README emphasizes improving the development phase in Unity while the file tree organizes the code into clearly defined modules (CustomEditor, Editor, Tween, Utils, and Web).

##### Analyzing the File Structure
- Top-Level Directories/Modules:
- CustomEditor: Contains custom attribute classes that modify the Unity inspector.
- Editor: Contains scripts that add new editor menu options and tools like asset management and script cleanup.
- Tween: Includes scripts for tweening (animations) along with extensions to existing Unity behavior.
- Utils: Provides general-purpose extension methods and helper functions (e.g., transform extensions, saving, pooling, waiting).
- Web: Provides web-related functionality such as picture downloading.
- Each module is organized as a self-contained library (note the .asmdef file in Helper indicates assembly definition setup), making it easier to see dependencies between modules.
- Configuration / package files (package.json) reveal integration via Unity Package Manager.

##### Architecture and Component Relationships
- The primary components of the system are:
A. Custom Attributes (in CustomEditor):
- Implements ButtonLUFI, ReadOnlyLUFI, and ShowIf functionalities.
- These components are directly used by developers in their MonoBehaviour scripts to extend and control behavior in the Unity Inspector.
B. Editor Tools (in Editor):
- Groups assets, folder, and package management alongside a tool for removing missing scripts.
- These tools integrate with Unity’s Editor environment (accessible via custom menus) to perform project-wide operations.
C. Tween System (in Tween):
- Provides tweening logic (animation of values over time) with helper buttons and runner scripts.
- This module interacts with both runtime and editor aspects where visual transitions or interpolations are needed.
D. Utility Functions (in Utils):
- Compromises various helper methods including extension functions for transforms, conversion utilities, pooling buckets, save system, and waiter functions.
- These utilities are used by both editor and runtime modules (for instance, to simplify common tasks).
E. Web Module (in Web):
- Handles external resource retrieval like picture downloading and additional web-related functionalities.
- May communicate with external servers or APIs if needed.
- Interactions:
- Custom attributes are applied to MonoBehaviour or ScriptableObject classes, thereby linking the CustomEditor logic with the core user scripts.
- Editor Tools will be visible as custom menu options in the Unity Editor and often use Utility functions to execute their operations.
- Tween and Utils operate as service libraries that can be called from both runtime and editor contexts.
- Web functionalities can be invoked by editor tools or even runtime components if web-based asset retrieval is required.

##### Key Architectural Patterns and Design Principles
- Modular Design: Each folder represents a distinct module with single responsibility. This separation is maintained via the assembly definition, ensuring loose coupling.
- Dependency Inversion and Extension: The CustomEditor and Utils modules serve as extension points, injecting custom behavior into the Unity Editor workflow.
- Layered Architecture: The system is layered by usage within the Unity environment (editor enhancements, runtime utilities, and helper libraries).
- Reusability: Utility functions (e.g., transformer enhancements and tweening) are abstracted so that multiple components (editor tools and runtime functionalities) can benefit from them.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Central Unity Editor Environment
    UE["Unity Editor Environment"]:::unity

    %% Custom Attributes Subgraph
    subgraph "Custom Inspector Attributes"
        CA1["ButtonLUFIAttribute"]:::custom
        CA2["ReadOnlyLUFIAttribute"]:::custom
        CA3["ShowIfAttribute"]:::custom
    end

    %% Editor Tools Subgraph
    subgraph "Editor Menu Tools"
        ET1["AssetManagementTool"]:::editor
        ET2["FolderManagementTool"]:::editor
        ET3["MissingScriptRemover"]:::editor
        ET4["PackageManagementTool"]:::editor
    end

    %% Tween System Subgraph
    subgraph "Tween Module"
        TW1["Tween"]:::tween
        TW2["TweenExtention"]:::tween
        TW3["TweenHelperButton"]:::tween
        TW4["TweenRunner"]:::tween
    end

    %% Utility Functions Subgraph
    subgraph "Utilities"
        UT1["Extension"]:::utils
        UT2["NumberConvert"]:::utils
        UT3["PoolBucket"]:::utils
        UT4["SaveSystem"]:::utils
        UT5["Waiter"]:::utils
    end

    %% Web Module Subgraph
    subgraph "Web Module"
        WB1["PictureDownloader"]:::web
        WB2["Web"]:::web
    end

    %% Connections from Unity Editor Environment to modules (using representative nodes)
    UE -->|"extendsInspector"| CA1
    UE -->|"customMenus"| ET1
    UE -->|"tweenEffects"| TW1
    UE -->|"sharedUtilities"| UT1
    UE -->|"webServices"| WB1

    %% Inter-module interactions
    CA1 -->|"influences"| ET1
    ET1 -->|"usesUtility"| UT1
    TW1 -->|"usesUtility"| UT1
    WB1 -->|"feedsEditorTools"| ET1
    WB1 -->|"feedsUtilities"| UT1

    %% Click Events for Custom Attributes
    click CA1 "https://github.com/lufias-69/helper-unity/blob/main/CustomEditor/ButtonLUFIAttribute.cs"
    click CA2 "https://github.com/lufias-69/helper-unity/blob/main/CustomEditor/ReadOnlyLUFIAttribute.cs"
    click CA3 "https://github.com/lufias-69/helper-unity/blob/main/CustomEditor/ShowIfAttribute.cs"

    %% Click Events for Editor Tools
    click ET1 "https://github.com/lufias-69/helper-unity/blob/main/Editor/AssetManagementTool.cs"
    click ET2 "https://github.com/lufias-69/helper-unity/blob/main/Editor/FolderManagementTool.cs"
    click ET3 "https://github.com/lufias-69/helper-unity/blob/main/Editor/MissingScriptRemover.cs"
    click ET4 "https://github.com/lufias-69/helper-unity/blob/main/Editor/PackageManagementTool.cs"

    %% Click Events for Tween System
    click TW1 "https://github.com/lufias-69/helper-unity/blob/main/Tween/Tween.cs"
    click TW2 "https://github.com/lufias-69/helper-unity/blob/main/Tween/TweenExtention.cs"
    click TW3 "https://github.com/lufias-69/helper-unity/blob/main/Tween/TweenHelperButton.cs"
    click TW4 "https://github.com/lufias-69/helper-unity/blob/main/Tween/TweenRunner.cs"

    %% Click Events for Utility Functions
    click UT1 "https://github.com/lufias-69/helper-unity/blob/main/Utils/Extension.cs"
    click UT2 "https://github.com/lufias-69/helper-unity/blob/main/Utils/NumberConvert.cs"
    click UT3 "https://github.com/lufias-69/helper-unity/blob/main/Utils/PoolBucket.cs"
    click UT4 "https://github.com/lufias-69/helper-unity/blob/main/Utils/SaveSystem.cs"
    click UT5 "https://github.com/lufias-69/helper-unity/blob/main/Utils/Waiter.cs"

    %% Click Events for Web Module
    click WB1 "https://github.com/lufias-69/helper-unity/blob/main/Web/PictureDownloader.cs"
    click WB2 "https://github.com/lufias-69/helper-unity/blob/main/Web/Web.cs"

    %% Styles
    classDef unity fill:#FFEB3B,stroke:#333,stroke-width:2px;
    classDef custom fill:#FFCC80,stroke:#333,stroke-width:2px;
    classDef editor fill:#81D4FA,stroke:#333,stroke-width:2px;
    classDef tween fill:#CE93D8,stroke:#333,stroke-width:2px;
    classDef utils fill:#A5D6A7,stroke:#333,stroke-width:2px;
    classDef web fill:#FFAB91,stroke:#333,stroke-width:2px;
```
