# nicktasticdev/exprite-unity architecture

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

- Interactive diagram: https://gitdiagram.com/nicktasticdev/exprite-unity
- Repository: https://github.com/nicktasticdev/exprite-unity

## Overview

##### Project type and purpose
- This is a Unity package (“Exprite for Unity”) that provides both an Editor extension and Runtime components to parse and play Sparrow/Starling spritesheets in Unity.
- Key purpose: import Sparrow spritesheet assets into Unity (via an Editor importer), generate ScriptableObject animation packs, and provide a runtime ExpriteRenderer component to display those animations at play time.

##### File structure
- Top-level:
- Misc/ – importer presets
- Scripts/Editor/ – Unity Editor extension code, including windows, inspectors, and .asmdef for Editor assembly
- Scripts/Runtime/ – runtime plugin code, including components, models, scriptable objects, and .asmdef for runtime assembly
- package.json – Unity package manifest
- Notable patterns:
- Separation of Editor code (folder + Exprite.Editor.asmdef) from Runtime code (folder + Exprite.asmdef)
- Models folder holds data classes (AnimationDefinition, SubTexture, TextureAtlas) used by both importer and runtime
- ScriptableObjects folder holds the generated ExpriteAnimationPack asset

##### README for additional insights
- Confirms the package is in development and targets Unity 6000.0+
- Describes core feature: parsing and playing Sparrow/Starling spritesheets, supporting internal and external asset loading

##### Main components and their interactions
a. Editor Extension
- ExpriteWindow (UI)
- Custom Inspectors: ExpriteAnimationPackEditor, ExpriteRendererEditor
- Importer preset: ExpriteTextureImporter.preset
- Runs in Unity Editor to parse source spritesheets, build TextureAtlas & AnimationDefinition models, and generate ExpriteAnimationPack ScriptableObject assets
b. Runtime Plugin
- ExpriteRenderer component attaches to GameObjects in scenes
- Reads ExpriteAnimationPack assets (from Resources/StreamingAssets or direct assets)
- Uses Model classes (AnimationDefinition, SubTexture, TextureAtlas) to drive animation logic and feed Unity’s Mesh/Renderer sub‐system
c. Assets & ScriptableObjects
- Image files (PNG, atlas) live under Images/ or loaded externally
- ExpriteAnimationPack ScriptableObjects store metadata about frame sequences
d. External Services / Data Sources
- Optional runtime streaming from StreamingAssets or a custom URL loader

##### Architectural patterns and design principles
- Clear separation of concerns: Editor vs Runtime assemblies
- Data‐driven design: Models + ScriptableObjects encapsulate all animation data
- Unity best practices: .asmdef files to isolate compilation, custom Inspectors to enhance UX
- Extensibility: importer preset can be swapped; runtime loader can be extended

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Assets Layer
    subgraph "Assets Layer"
        rawImages["Images/ Icons"]:::assets
        packageJson["package.json"]:::assets
    end

    %% Editor Layer
    subgraph "Editor Layer"
        asmdefEd["Exprite.Editor.asmdef"]:::editor
        window["ExpriteWindow"]:::editor
        inspPackEd["ExpriteAnimationPackEditor"]:::editor
        inspRendEd["ExpriteRendererEditor"]:::editor
        importerPreset["ExpriteTextureImporter.preset"]:::editor
    end

    %% Generated Assets
    subgraph "Generated Assets"
        soPack["ExpriteAnimationPack (ScriptableObject)"]:::assets
    end

    %% Runtime Layer
    subgraph "Runtime Layer"
        asmdefRt["Exprite.asmdef"]:::runtime
        animDef["AnimationDefinition"]:::runtime
        subTex["SubTexture"]:::runtime
        texAtlas["TextureAtlas"]:::runtime
        renderer["ExpriteRenderer"]:::runtime
        renderPipe["Unity Render Pipeline"]:::runtime
        loader["Runtime Loader"]:::runtime
    end

    %% External Data
    subgraph "External Data"
        extData["StreamingAssets/ Remote URL"]:::external
    end

    %% Connections
    rawImages -->|provides sprites| importerPreset
    window -->|invokes| importerPreset
    inspPackEd -->|customizes| soPack
    inspRendEd -->|customizes| renderer
    importerPreset -->|generates| animDef
    importerPreset -->|generates| subTex
    importerPreset -->|generates| texAtlas
    animDef -->|populates| soPack
    subTex -->|populates| soPack
    texAtlas -->|populates| soPack

    soPack -->|loaded by| renderer
    asmdefRt -->|compiles with| renderer
    asmdefRt -->|compiles with| animDef
    asmdefRt -->|compiles with| subTex
    asmdefRt -->|compiles with| texAtlas
    renderer -->|drives| renderPipe

    extData -->|streamed via| loader
    loader -->|provides animations to| renderer

    %% Click Events
    click window "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Editor/ExpriteWindow.cs"
    click inspPackEd "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Editor/Editors/ExpriteAnimationPackEditor.cs"
    click inspRendEd "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Editor/Editors/ExpriteRendererEditor.cs"
    click asmdefEd "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Editor/Exprite.Editor.asmdef"
    click importerPreset "https://github.com/nicktasticdev/exprite-unity/blob/master/Misc/ExpriteTextureImporter.preset"
    click renderer "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Runtime/Components/ExpriteRenderer.cs"
    click asmdefRt "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Runtime/Exprite.asmdef"
    click animDef "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Runtime/Models/Exprite/AnimationDefinition.cs"
    click subTex "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Runtime/Models/Sparrow/SubTexture.cs"
    click texAtlas "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Runtime/Models/Sparrow/TextureAtlas.cs"
    click soPack "https://github.com/nicktasticdev/exprite-unity/blob/master/Scripts/Runtime/ScriptableObjects/ExpriteAnimationPack.cs"
    click rawImages "https://github.com/nicktasticdev/exprite-unity/tree/master/Images/Icons"

    %% Styling
    classDef editor fill:#D6EAF8,stroke:#21618C,color:#1B4F72
    classDef runtime fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef assets fill:#FCF3CF,stroke:#B9770E,color:#7E5109
    classDef external fill:#E5E8E8,stroke:#616A6B,color:#434A4E
```
