How yasirkula/unitybeziersolution works
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.