# yasirkula/unitybeziersolution architecture

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

- Interactive diagram: https://gitdiagram.com/yasirkula/unitybeziersolution
- Repository: https://github.com/yasirkula/unitybeziersolution

## Overview

##### Main Components
- Core Runtime:
- Spline and Point Data Structures – represented by classes like BezierSpline, BezierPoint, and assorted data structures within the “Other” folder.
- Attributes & Utility Functions – components such as MinMaxRangeAttribute and helper utilities (e.g., for mesh bending, point interpolation, caching, and evenly spaced points).
- Editor Tools:
- Editor Scripts – found under the “Editor” directory. These include custom inspectors (BezierSplineEditor, BezierPointEditor, etc.) that enable the visual manipulation of splines in the Unity Editor.
- Editor Configurations – settings that allow you to tweak scene view gizmos and other in-editor behaviors.
- Demo Scene:
- Demo Components – a demo scene and related assets in the “Demo” folder that illustrate how a Bezier spline is created, manipulated, and connected to game objects.
- Utility Components:
- Spline-Based Behaviors – components in the “Utilities” folder such as BezierWalkerWithSpeed, BezierWalkerWithTime, ParticlesFollowBezier, BendMeshAlongBezier, and BezierLineRenderer. These drive runtime objects along the spline or modify meshes/particles to follow the spline path.

##### Relationships and Interactions
- The Core Runtime layer defines the mathematical and logical handling of Bezier splines (defining endpoints, control points, normals, and interpolation methods). This module is used by:
- Editor Tools that render visual controls and provide interactive editing in the Unity Editor.
- Utility Components that drive runtime behaviors by reading spline data (e.g., moving objects, calculating walkers, or bending meshes).
- The Editor Modules listen for and respond to changes in spline properties (via the onSplineChanged event) and invoke auto recalculation routines (like auto-construct or auto-calculation of normals).
- The Demo scene serves to exemplify the integration between core spline logic, editor controls, and runtime utility behaviors.

##### Architectural Patterns and Design Principles
- Modularity: Notice how the project separates distinct concerns (core functionality, editor support, demo presentation, utility behaviors) into different folders.
- MVC-like Separation: While not strictly MVC, there is a clear separation between the data/model (spline/point definitions), the view (editor gizmos and inspector UI), and the controller (utility components driving the runtime behaviors).
- Event-Driven Communication: The use of events such as onSplineChanged demonstrates a reactive design where updates in the spline trigger appropriate recalculations.

##### Relevant Technologies, Frameworks, and Libraries
- Unity Engine and Editor scripting (C#).
- Custom Assembly Definitions (*.asmdef files) for segregating runtime and editor code.
- The project builds upon ideas from Catlike Coding’s spline tutorial, so some design concepts (like smooth spline interpolation and control point arrangement) are inherited from that base.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core Spline Calculation"
        BS["BezierSpline"]:::core
        BP["BezierPoint"]:::core
        DS["Data Structures"]:::core
    end

    AT["MinMaxRangeAttribute"]:::attribute

    subgraph "Editor Module"
        BSE["BezierSplineEditor"]:::editor
        BPE["BezierPointEditor"]:::editor
        EC["Editor Configurations"]:::editor
    end

    subgraph "Runtime Utilities"
        BW["BezierWalker"]:::util
        BWS["BezierWalkerWithSpeed"]:::util
        BWT["BezierWalkerWithTime"]:::util
        BMB["BendMeshAlongBezier"]:::util
        PF["ParticlesFollowBezier"]:::util
        BLR["BezierLineRenderer"]:::util
    end

    D["Demo Scene"]:::demo

    %% Data flow connections
    BS -->|"providesData"| BSE
    BP -->|"providesData"| BPE
    BS -->|"uses"| AT
    BS -->|"triggers_onSplineChanged"| BSE
    BS -->|"drives"| BW
    BS -->|"feeds"| BWT
    BP -->|"drives"| PF
    DS -->|"supports"| AT

    %% Integration with Demo
    BSE -->|"updates"| D
    BW -->|"controls_movement"| D

    %% Styling classes
    classDef core fill:#cce5ff,stroke:#000,stroke-width:2px;
    classDef attribute fill:#d4edda,stroke:#000,stroke-width:2px;
    classDef editor fill:#fff3cd,stroke:#000,stroke-width:2px;
    classDef util fill:#ffe5b4,stroke:#000,stroke-width:2px;
    classDef demo fill:#f5e1ff,stroke:#000,stroke-width:2px;

    %% Click Events
    click BS "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/BezierSpline.cs"
    click BP "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/BezierPoint.cs"
    click DS "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Other/BezierDataStructures.cs"
    click AT "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Attributes/MinMaxRangeAttribute.cs"
    click BSE "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Editor/BezierSplineEditor.cs"
    click BPE "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Editor/BezierPointEditor.cs"
    click EC "https://github.com/yasirkula/unitybeziersolution/tree/master/Plugins/BezierSolution/Editor"
    click D "https://github.com/yasirkula/unitybeziersolution/tree/master/Plugins/BezierSolution/Demo"
    click BW "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Utilities/BezierWalker.cs"
    click BWS "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Utilities/BezierWalkerWithSpeed.cs"
    click BWT "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Utilities/BezierWalkerWithTime.cs"
    click BMB "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Utilities/BendMeshAlongBezier.cs"
    click PF "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Utilities/ParticlesFollowBezier.cs"
    click BLR "https://github.com/yasirkula/unitybeziersolution/blob/master/Plugins/BezierSolution/Utilities/BezierLineRenderer.cs"
```
