Example #1
0
            internal SplineComputer CreateSplineComputer(Vector3 position, Quaternion rotation)
            {
                GameObject go = new GameObject(name);

                go.transform.position = position;
                go.transform.rotation = rotation;
                SplineComputer computer = go.AddComponent <SplineComputer>();

#if UNITY_EDITOR
                if (Application.isPlaying)
                {
                    computer.ResampleTransform();
                }
#endif
                computer.type = type;
                if (closed)
                {
                    if (points[0].type == SplinePoint.Type.Broken)
                    {
                        points[0].SetTangentPosition(GetLastPoint().tangent2);
                    }
                }
                computer.SetPoints(points.ToArray(), SplineComputer.Space.Local);
                if (closed)
                {
                    computer.Close();
                }
                return(computer);
            }
 public void UpdateSpline()
 {
     if (spline == null)
     {
         return;
     }
     if (!isClosed && spline.isClosed)
     {
         spline.Break();
     }
     else if (spline.isClosed && points.Length < 4)
     {
         spline.Break();
         isClosed = false;
     }
     spline.SetPoints(points);
     if (isClosed && !spline.isClosed)
     {
         spline.Close();
     }
     spline.type       = splineType;
     spline.sampleRate = sampleRate;
     spline.is2D       = is2D;
     spline.EditorUpdateConnectedNodes();
 }
 public virtual void Close()
 {
     if (lastClosed)
     {
         computer.Close();
     }
     else
     {
         computer.Break();
     }
     computer.SetPoints(lastPoints, SplineComputer.Space.Local);
     computer.type = lastType;
 }
Example #4
0
 public void UpdateSplineComputer(SplineComputer comp)
 {
     Generate();
     ApplyOffset();
     comp.type = GetSplineType();
     comp.SetPoints(points, SplineComputer.Space.Local);
     if (closed)
     {
         comp.Close();
     }
     else if (comp.isClosed)
     {
         comp.Break();
     }
 }
Example #5
0
        public SplineComputer CreateSplineComputer(string name, Vector3 position, Quaternion rotation)
        {
            Generate();
            ApplyOffset();
            GameObject     go   = new GameObject(name);
            SplineComputer comp = go.AddComponent <SplineComputer>();

            comp.SetPoints(points, SplineComputer.Space.Local);
            if (closed)
            {
                comp.Close();
            }
            comp.transform.position = position;
            comp.transform.rotation = rotation;
            return(comp);
        }
Example #6
0
        public SplineComputer CreateSplineComputer(string name, Vector3 position, Quaternion rotation)
        {
            Generate();
            ApplyOffset();
            GameObject     gameObject     = new GameObject(name);
            SplineComputer splineComputer = gameObject.AddComponent <SplineComputer>();

            splineComputer.type = type;
            splineComputer.SetPoints(points, SplineComputer.Space.Local);
            if (closed)
            {
                splineComputer.Close();
            }
            splineComputer.transform.position = position;
            splineComputer.transform.rotation = rotation;
            return(splineComputer);
        }
Example #7
0
            internal SplineComputer CreateSplineComputer(Vector3 position, Quaternion rotation)
            {
                GameObject gameObject = new GameObject(name);

                gameObject.transform.position = position;
                gameObject.transform.rotation = rotation;
                SplineComputer splineComputer = gameObject.AddComponent <SplineComputer>();

                splineComputer.type = type;
                if (closed && points[0].type == SplinePoint.Type.Broken)
                {
                    SplinePoint splinePoint = points[0];
                    SplinePoint lastPoint   = GetLastPoint();
                    splinePoint.SetTangentPosition(lastPoint.tangent2);
                }
                splineComputer.SetPoints(points.ToArray(), SplineComputer.Space.Local);
                if (closed)
                {
                    splineComputer.Close();
                }
                return(splineComputer);
            }