Exemple #1
0
        void Update()
        {
            if (!Application.isPlaying)
            {
                if (usedVolume == softVolume.volume &&
                    usedScale == softVolume.partixScale)
                {
                    return;
                }
                usedVolume = softVolume.volume;
                usedScale  = softVolume.partixScale;
                if (usedVolume != null)
                {
                    SetUpFromStaticData();
                }
            }
            else
            {
                if (!softVolume.Ready())
                {
                    return;
                }

                int[] indices = softVolume.GetWireFrameIndices();
                mesh.vertices = softVolume.GetWireFrameVertices();
                mesh.SetIndices(indices, MeshTopology.Lines, 0);

                VehiclePointLoad[] vpl = softVolume.GetPointLoads();
                colors = new Color[vpl.Length];
                for (int i = 0; i < colors.Length; i++)
                {
                    var c = new Color(0, 0, 0);
                    if (renderWeight)
                    {
                        c.r = vpl[i].weight;
                    }
                    if (renderFriction)
                    {
                        c.g = vpl[i].friction;
                    }
                    if (renderAccel)
                    {
                        c.b = vpl[i].accel;
                    }
                    colors[i] = c;
                }
                mesh.colors = colors;
            }
        }