private void Start() { if (currentSpline == null) { return; } _distance = currentSpline.GetTotalDistance(); _progress = 0.5f; //reset progress _cicleDuration = 0; }
/// <summary> /// Calculate mesh generation parameters /// </summary> private void CreateMesh() { if (_auxTransform1 != null) { GetAuxTranforms(); } if (_auxTransform1 == null) { return; } float totalDistance = _spline.GetTotalDistance(); for (float dist = 0.0f; dist < totalDistance; dist += _baseMeshLength) { float initialT = Mathf.Clamp01(dist / totalDistance); float finalT = Mathf.Clamp01((dist + _baseMeshLength) / totalDistance); OrientedPoint startPoint = _spline.GetOrientedPoint(initialT); OrientedPoint endPoint = _spline.GetOrientedPoint(finalT); _auxTransform1.rotation = startPoint.Rotation; _auxTransform1.position = startPoint.Position + meshOffset; _auxTransform2.rotation = endPoint.Rotation; _auxTransform2.position = endPoint.Position + meshOffset; bool exceededVertsLimit = false; bool notUVMapped = false; AddSegment(_auxTransform1, _auxTransform2, out exceededVertsLimit, out notUVMapped); if (notUVMapped) { break; } if (exceededVertsLimit) { realtimeMeshGeneration = false; break; } } }