public SomeCurveData(MyCurveData referenceCurve, string name, Vector3 position, BGCurveBaseMath.Config config) : base(new GameObject(name), referenceCurve.LineRendererMaterial, Color.magenta) { this.referenceCurve = referenceCurve; //game object GameObject.transform.parent = referenceCurve.GameObject.transform.parent; GameObject.transform.localScale = localScale; GameObject.transform.position = position; origin = position; //curve Curve = GameObject.AddComponent <BGCurve>(); Curve.Closed = referenceCurve.Curve.Closed; //add points for (var i = 0; i < referenceCurve.Curve.PointsCount; i++) { Curve.AddPoint(referenceCurve.Curve[i].CloneTo(Curve)); } //init math after points are added Math = new BGCurveBaseMath(Curve, config); AddObjects(ObjectsCount, referenceCurve.ObjectToMove, referenceCurve.Curve.transform.parent); }
// Use this for initialization private void Start() { myCurveData = new MyCurveData(GetComponent <BGCurve>(), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent), ObjectToMove, LineRendererMaterial); //UsePointPositionsToCalcTangents myCurveData.Add(new SomeCurveData(myCurveData, "BGRuntimePos2TangentsWorld", transform.position + new Vector3(4, 3), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent) { UsePointPositionsToCalcTangents = true })); //OptimizeStraightLines myCurveData.Add(new SomeCurveData(myCurveData, "BGRuntimeStraightLinesWorld", transform.position + new Vector3(-4, 3), new BGCurveBaseMath.Config(BGCurveBaseMath.Fields.PositionAndTangent) { OptimizeStraightLines = true })); }