Overview

Project Structure

There are 3 distinctive modular layers, each on top of the others. Lower layers are not aware of the layers above them (this also imply code dependencies).
1) Spline core (spline itself with points and fields). Mostly data only.
2) Two math implementations (Uniform and Adaptive) on top of the core.
3) Curve's components (Cc)- set of classes, adding some additional functions to spline, like moving an object along etc.

Note: the core itself is not customizable, however you can customize any other layer.For example, you can implement your own math implementation or add your own components.

Source Code Structure

Overall idea how source code is organized.

Spline Components

Components are the standard Unity MonoBehaviour subclasses, which gives you access to some additional spline's related functions at Play mode without any scripting. We recommend to use them unless they do not cover your needs. For example, if you need math, do not create BGCurveBaseMath yourself, simply attach BGCcMath component and reference it instead of BGCurve.

Creating Custom Component

You can create your own custom component. There are 4 requirements for it:
1) Component should extends BGCc class.
2) Component's editor should extends BGCcEditor class (see existing components for example)
3) Component should have a descriptor attribute (CcDescriptor) attached.
4) Component should have only one (0-min, 1-max) RequireComponent of type BGCc, which will be considered as it's parent.

Custom Fields

Custom fields are additional fields, that can be attached to every point. There is a set of supported types, that can be used as type of custom field, but you can attach any type (even if it's not supported) by using Unity's standard Component type and assigning your MonoBehaviour's derived object to it.

Points store options

Points of the spline can be stored:
1) Inlined (right inside spline's component (BGCurve) with minimum memory and serialization overhead). Default option.
2) As Components (every point is extended from MonoBehaviour and attached to spline's GameObject). This will add the possibility to reference separate point.
3) As GameObjects with No Transform (every point is attached to it's own separate GameObject), transform is ignored.
4) As GameObjects with Transform (every point is attached to it's own separate GameObject), transform is used as point position and affects controls positions.

Events

BGCurve.Changed event is fired once per frame in Update (or LateUpdate (configurable)) spline's method if spline is changed. Math uses this event to update it's cached data. if you need to update some data after math is changed, use math.Changed event instead of curve.Changed. Or alternatively use BGCcMath component, which has Unity standard persistent event (mathChanged) as well as non persistent one.