Ejemplo n.º 1
0
        /// <summary>
        /// Updates Spline Mesh renderer (if exists)
        /// </summary>
        private void UpdateMeshRenderer()
        {
            SplineMeshRenderer splineMeshRenderer = GetComponent <SplineMeshRenderer>();

            if (splineMeshRenderer != null)
            {
                splineMeshRenderer.ExtrudeMesh();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create new renderer at the end of the current one
        /// </summary>
        public GameObject ConnectNewRenderer()
        {
            Vector3    lastPointPosition = _spline.GetControlPointPosition(_spline.ControlPointCount - 1);
            Quaternion lastPointRotation = _spline.GetRotation(1);

            Vector3    position = transform.TransformPoint(lastPointPosition);
            GameObject clone    = Instantiate(this.gameObject, position, _spline.GetRotation(1) * Quaternion.LookRotation(_spline.GetDirection(1)));

            Spline newRendererSpline = clone.GetComponent <Spline>();

            newRendererSpline.Reset();
            newRendererSpline.ResetRotations(lastPointRotation);

            SplineMeshRenderer newRendererSplineMeshRenderer = clone.GetComponent <SplineMeshRenderer>();

            newRendererSplineMeshRenderer.realtimeMeshGeneration = realtimeMeshGeneration;
            newRendererSplineMeshRenderer.ExtrudeMesh();

            return(clone);
        }