void OnValidate()
        {
            if (m_firstDeserialization)
            {
            m_materialsLength = groundMaterials.Length;
            m_firstDeserialization = false;
            }
            else
            {
            if (groundMaterials.Length != m_materialsLength)
                {
                if (m_materialsLength == 0)
                    {
                    for (int i = 0; i < groundMaterials.Length; i++)
                        groundMaterials[i] = new GroundMaterial();
                    }

                m_materialsLength = groundMaterials.Length;
                }
            }
        }
        // Updates a ground material reference based on the physics material assigned to a collider
        // using a cached reference for the physics material. This way the ground material manager
        // is queried only when the physic material changes.
        void UpdateGroundMaterialCached(PhysicMaterial colliderMaterial, ref PhysicMaterial cachedMaterial, ref GroundMaterial groundMaterial)
        {
            if (m_groundMaterialManager != null)
            {
            // Query the ground material (slow, table look-up) only when the physic material changes.
            // Otherwise keep the actual known material.

            if (colliderMaterial != cachedMaterial)
                {
                cachedMaterial = colliderMaterial;
                groundMaterial = m_groundMaterialManager.GetGroundMaterial(colliderMaterial);
                }
            }
            else
            {
            groundMaterial = null;
            }
        }