public static CatmullRomSpline SplineOfPoints(List <Vector3> pts)
        {
            GameObject splineObj = new GameObject();

            CatmullRomSpline spline = splineObj.AddComponent <CatmullRomSpline>();

            spline.points = new List <Vector3>();
            spline.points.AddRange(pts);
            spline.SetMaterial(DesignerController.instance.defaultLineMaterial);

            spline.name = "spline" + numSplinesCreated;
            numSplinesCreated++;

            return(spline);
        }
Beispiel #2
0
        /// <summary>
        /// Add a new spline object to this canvas, and add an initial control
        /// point for it.
        /// </summary>
        /// <param name="firstPos">The position of the first control point.</param>
        /// <returns></returns>
        CatmullRomSpline AddSpline(Vector3 firstPos)
        {
            GameObject splineObj = new GameObject();

            splineObj.transform.parent = transform;

            mostRecentPoint = firstPos;
            CatmullRomSpline spline = splineObj.AddComponent <CatmullRomSpline>();

            spline.points = new List <Vector3>();
            spline.points.Add(firstPos - 0.1f * Vector3.up);
            spline.points.Add(firstPos);
            spline.points.Add(firstPos + 0.1f * Vector3.up);
            spline.points.Add(firstPos + 0.2f * Vector3.up);
            spline.containingCanvas = this;
            splines.Add(spline);
            spline.SetMaterial(DesignerController.instance.defaultLineMaterial);

            splineObj.name = "spline" + splines.Count;
            return(spline);
        }