Ejemplo n.º 1
0
        public void Update()
        {
            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 = (1f / (LineStepCount - 1)) * i;
                positions.Add(LineDataSource.GetPoint(normalizedDistance));
                colors.Add(GetColor(normalizedDistance));
                widths.Add(GetWidth(normalizedDistance));
                forwards.Add(LineDataSource.GetRotation(normalizedDistance) * Vector3.down);
            }

            GenerateStripMesh(positions, colors, widths, uvOffset, forwards, stripMesh);
        }
Ejemplo n.º 2
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.º 4
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);
            }
        }