I have a class, SplineController, which I want to allow to have different types of splines to be used for different purposes (as they have different properties). All my spline classes implement an interface, ISpline.
public class SplineController
{
public ISpline positionSpline;
public void Start()
{
// Obtain SplineControllerWaypoint objects and add points to the ISpline
SplineAnimationControllerWaypoint[] waypoints =
transform.parent.GetComponentsInChildren<SplineAnimationControllerWaypoint>();
foreach (SplineAnimationControllerWaypoint waypoint in waypoints)
{
positionSpline.AddPoint(waypoint.position);
}
positionSpline.Build();
}
}
Now I would like to specify which script to use to create the instance of ISpline from through the inspector. What is the way to select the script and create the ISpline instance from there?