protected override void UpdateLine()
        {
            if (stripMeshRenderer == null)
            {
                Debug.LogError("Strip mesh renderer has been destroyed - disabling");
                enabled = false;
            }

            if (!LineDataSource.enabled)
            {
                stripMeshRenderer.enabled = false;
                return;
            }

            stripMeshRenderer.enabled = true;
            positions.Clear();
            forwards.Clear();
            colors.Clear();
            widths.Clear();

            for (int i = 0; i <= LineStepCount; i++)
            {
                float normalizedDistance = GetNormalizedPointAlongLine(i);
                positions.Add(LineDataSource.GetPoint(normalizedDistance));
                colors.Add(GetColor(normalizedDistance));
                widths.Add(GetWidth(normalizedDistance));
                forwards.Add(LineDataSource.GetVelocity(normalizedDistance));
            }

            GenerateStripMesh(positions, colors, widths, uvOffset, forwards, stripMesh, LineDataSource.LineTransform.up);
        }
 private void LateUpdate()
 {
     // Update our helper mesh so OnWillRenderObject will be called
     meshVertices[0]       = transform.InverseTransformPoint(LineDataSource.GetPoint(0.0f)); // - transform.position;
     meshVertices[1]       = transform.InverseTransformPoint(LineDataSource.GetPoint(0.5f)); // - transform.position;
     meshVertices[2]       = transform.InverseTransformPoint(LineDataSource.GetPoint(1.0f)); // - transform.position;
     renderedMesh.vertices = meshVertices;
     renderedMesh.RecalculateBounds();
 }
        private void Update()
        {
            if (LineDataSource == null)
            {
                enabled = false;
                lineRenderer.enabled = false;
                return;
            }

            lineRenderer.enabled       = LineDataSource.enabled;
            lineRenderer.positionCount = StepMode == StepMode.FromSource ? LineDataSource.PointCount : LineStepCount;

            if (positions == null || positions.Length != lineRenderer.positionCount)
            {
                positions = new Vector3[lineRenderer.positionCount];
            }

            for (int i = 0; i < positions.Length; i++)
            {
                if (StepMode == StepMode.FromSource)
                {
                    positions[i] = LineDataSource.GetPoint(i);
                }
                else
                {
                    float normalizedDistance = (1f / (LineStepCount - 1)) * i;
                    positions[i] = LineDataSource.GetPoint(normalizedDistance);
                }
            }

            // Set line renderer properties
            lineRenderer.loop              = LineDataSource.Loops;
            lineRenderer.numCapVertices    = roundedCaps ? 8 : 0;
            lineRenderer.numCornerVertices = roundedEdges ? 8 : 0;
            lineRenderer.useWorldSpace     = true;
            lineRenderer.startWidth        = 1;
            lineRenderer.endWidth          = 1;
            lineRenderer.startColor        = Color.white;
            lineRenderer.endColor          = Color.white;
            lineRenderer.sharedMaterial    = lineMaterial;
            lineRenderer.widthCurve        = LineWidth;
            lineRenderer.widthMultiplier   = WidthMultiplier;
            lineRenderer.colorGradient     = LineColor;
            lineRenderer.shadowCastingMode = ShadowCastingMode.Off;
            lineRenderer.lightProbeUsage   = LightProbeUsage.Off;

            // Set positions
            lineRenderer.positionCount = positions.Length;
            lineRenderer.SetPositions(positions);
        }
Ejemplo n.º 4
0
        private void Update()
        {
            if (!LineDataSource.enabled)
            {
                mainNoiseModule.enabled     = particleNoiseOnDisabled;
                mainNoiseModule.strengthX   = noiseStrength.x;
                mainNoiseModule.strengthY   = noiseStrength.y;
                mainNoiseModule.strengthZ   = noiseStrength.z;
                mainNoiseModule.octaveCount = noiseOcatives;
                mainNoiseModule.scrollSpeed = noiseSpeed;
                mainNoiseModule.frequency   = noiseFrequency;

                if (decayStartTime < 0)
                {
                    decayStartTime = Time.unscaledTime;
                }
            }
            else
            {
                mainNoiseModule.enabled = false;
                decayStartTime          = -1;
            }

            if (LineDataSource.enabled)
            {
                for (int i = 0; i < LineStepCount; i++)
                {
                    float normalizedDistance         = (1f / (LineStepCount - 1)) * i;
                    ParticleSystem.Particle particle = mainParticleArray[i];
                    particle.position    = LineDataSource.GetPoint(normalizedDistance);
                    particle.startColor  = GetColor(normalizedDistance);
                    particle.startSize   = GetWidth(normalizedDistance);
                    mainParticleArray[i] = particle;
                }
            }
            else
            {
                int numDecayingParticles = particles.GetParticles(mainParticleArray);

                for (int i = 0; i < numDecayingParticles; i++)
                {
                    float normalizedDistance = (1f / (LineStepCount - 1)) * i;
                    mainParticleArray[i].startColor = decayGradient.Evaluate((Time.unscaledTime - decayStartTime) / lifetimeAfterDisabled) * GetColor(normalizedDistance);
                }
            }

            particles.SetParticles(mainParticleArray, LineStepCount);
        }
Ejemplo n.º 5
0
        protected override void UpdateLine()
        {
            if (!Application.isPlaying)
            {   // This check is only necessary in edit mode.
                if (!IsInitialized)
                {
                    enabled = false;
                    return;
                }
            }

            if (LineDataSource.enabled)
            {
                meshTransforms.Clear();
                colorValues.Clear();
                linePropertyBlock.Clear();

                int skipCount = 0;

                for (int i = 0; i < LineStepCount; i++)
                {
                    if (lineStepSkip > 0)
                    {
                        skipCount++;
                        if (skipCount < lineStepSkip)
                        {
                            continue;
                        }

                        skipCount = 0;
                    }

                    float normalizedDistance = GetNormalizedPointAlongLine(i);
                    colorValues.Add(GetColor(normalizedDistance));
                    meshTransforms.Add(Matrix4x4.TRS(LineDataSource.GetPoint(normalizedDistance), LineDataSource.GetRotation(normalizedDistance), Vector3.one * GetWidth(normalizedDistance)));
                }

                if (useVertexColors)
                {
                    colorId = Shader.PropertyToID(colorProperty);
                    linePropertyBlock.SetVectorArray(colorId, colorValues);
                }

                Graphics.DrawMeshInstanced(lineMesh, 0, lineMaterial, meshTransforms, linePropertyBlock);
            }
        }
        private void Update()
        {
            executeCommandBuffer = false;

            if (LineDataSource.enabled)
            {
                if (meshTransforms == null || meshTransforms.Length != LineStepCount)
                {
                    meshTransforms = new Matrix4x4[LineStepCount];
                }

                if (colorValues == null || colorValues.Length != LineStepCount)
                {
                    colorValues = new Vector4[LineStepCount];
                    linePropertyBlock.Clear();
                }

                for (int i = 0; i < LineStepCount; i++)
                {
                    float normalizedDistance = (1f / (LineStepCount - 1)) * i;
                    colorValues[i]    = GetColor(normalizedDistance);
                    meshTransforms[i] = Matrix4x4.TRS(LineDataSource.GetPoint(normalizedDistance), LineDataSource.GetRotation(normalizedDistance), Vector3.one * GetWidth(normalizedDistance));
                }

                linePropertyBlock.SetVectorArray(colorId, colorValues);

                executeCommandBuffer = true;
            }
        }
Ejemplo n.º 7
0
        protected override void UpdateLine()
        {
            if (LineDataSource.enabled)
            {
                meshTransforms.Clear();
                colorValues.Clear();

                int skipCount = 0;

                for (int i = 0; i < LineStepCount; i++)
                {
                    if (lineStepSkip > 0)
                    {
                        skipCount++;
                        if (skipCount < lineStepSkip)
                        {
                            continue;
                        }

                        skipCount = 0;
                    }

                    float normalizedDistance = GetNormalizedPointAlongLine(i);
                    colorValues.Add(GetColor(normalizedDistance));
                    meshTransforms.Add(Matrix4x4.TRS(LineDataSource.GetPoint(normalizedDistance), LineDataSource.GetRotation(normalizedDistance), Vector3.one * GetWidth(normalizedDistance)));
                }

                colorId = Shader.PropertyToID(colorProperty);
                linePropertyBlock.Clear();
                linePropertyBlock.SetVectorArray(colorId, colorValues);
                Graphics.DrawMeshInstanced(lineMesh, 0, lineMaterial, meshTransforms, linePropertyBlock);
            }
        }