예제 #1
0
        /// <summary>
        /// Creates spline
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static SplineBase CreateSpline(SplineBase.SplineInfo info)
        {
            SplineBase spline = CreateSpline(info.points.ToVector3(), CourseBase.GetLayer(info.layerName, SplineLayers), (SplineBase.SplineInfo.Flags)info.flags, info.InstanceID);

            spline.Info.pin = info.pin;

            spline.UpdateLine();
            splines.Add(spline);
            spline.LineChanged();

            return(spline);
        }
예제 #2
0
        /// <summary>
        /// Creates spline
        /// </summary>
        /// <param name="points"></param>
        /// <param name="layer"></param>
        /// <param name="flags"></param>
        /// <param name="rearrange"></param>
        /// <returns></returns>
        public static SplineBase CreateSpline(Vector3[] points, Layer layer, SplineBase.SplineInfo.Flags flags, bool rearrange = false)
        {
            if ((flags & SplineBase.SplineInfo.Flags.Square) == 0 || rearrange)
            {
                points = points.ToList().RearrangePoints(layer.metersPerOnePoint).ToArray();
            }
            if (points.Length < 3)
            {
                return(null);
            }

            SplineBase spline = CreateSpline(points, layer, flags, FreeSplineInstanceID());

            spline.UpdateLine();
            splines.Add(spline);
            spline.LineChanged();

            return(spline);
        }
예제 #3
0
        /// <summary>
        /// Creates spline
        /// </summary>
        /// <param name="points"></param>
        /// <param name="layer"></param>
        /// <param name="flags"></param>
        /// <param name="instanceID"></param>
        /// <returns></returns>
        public static SplineBase CreateSpline(Vector3[] points, Layer layer, SplineBase.SplineInfo.Flags flags, int instanceID)
        {
            GameObject gameObject = new GameObject("Spline " + instanceID.ToString());

            if (PlatformBase.IO.IsEditor)
            {
                PlatformBase.Editor.RegisterCreatedObjectUndo(gameObject, "Spline tool Creation");
                PlatformBase.Editor.SetStaticFlags(gameObject);
                gameObject.hideFlags = HideFlags.HideInHierarchy;
            }

            SplineBase spline = (SplineBase)gameObject.AddComponent(Types.GetType("PerfectParallel.CourseForge.Spline", "Assembly-CSharp"));

            spline.Info.layerName  = layer.name;
            spline.Points          = (Vector3[])points.Clone();
            spline.Info.flags      = (int)flags;
            spline.Info.InstanceID = instanceID;

            spline.UpdateLine();
            splines.Add(spline);
            spline.LineChanged();

            return(spline);
        }