void Start() { // GUI has four types of objects. Controlpoints, in and out controls and a line between all of these. // All these are RageSpline objects, instantiated from a prefab controlPoints = new RageSpline[rageSpline.GetPointCount()]; inControlPoints = new RageSpline[rageSpline.GetPointCount()]; outControlPoints = new RageSpline[rageSpline.GetPointCount()]; handleLines = new RageSpline[rageSpline.GetPointCount()]; for (int index = 0; index < rageSpline.GetPointCount(); index++) { // Instantiate control point GUI object from the controlPointPrefab -prefab GameObject controlPointGO = Instantiate( controlPointPrefab, rageSpline.GetPositionWorldSpace(index) + new Vector3(0f, 0f, -1f), Quaternion.identity) as GameObject; // Save the new RageSpline instance reference of the GUI object controlPoints[index] = controlPointGO.GetComponent(typeof(RageSpline)) as RageSpline; controlPoints[index].SetFillColor1(unSelectedColor); // Instantiate inCtrl handle GUI object from the handleControlPointPrefab -prefab GameObject inControlPointGO = Instantiate( handleControlPointPrefab, rageSpline.GetInControlPositionWorldSpace(index) + new Vector3(0f, 0f, -1f), Quaternion.identity) as GameObject; // Save the new RageSpline instance reference of the GUI object inControlPoints[index] = inControlPointGO.GetComponent(typeof(RageSpline)) as RageSpline; inControlPoints[index].SetFillColor1(unSelectedColor); // Instantiate outCtrl handle GUI object from the handleControlPointPrefab -prefab GameObject outControlPointGO = Instantiate( handleControlPointPrefab, rageSpline.GetOutControlPositionWorldSpace(index) + new Vector3(0f, 0f, -1f), Quaternion.identity) as GameObject; // Save the new RageSpline instance reference of the GUI object outControlPoints[index] = outControlPointGO.GetComponent(typeof(RageSpline)) as RageSpline; outControlPoints[index].SetFillColor1(unSelectedColor); // Instantiate line GUI object from the handleLinePrefab -prefab GameObject handleLineGO = Instantiate( handleLinePrefab, rageSpline.GetPositionWorldSpace(index) + new Vector3(0f, 0f, -0.5f), Quaternion.identity) as GameObject; handleLines[index] = handleLineGO.GetComponent(typeof(RageSpline)) as RageSpline; } refreshEditorGUI(); }