Search Unity

I just destroyed the Plane primitive mesh

Discussion in 'Editor & General Support' started by WavyRancheros, Aug 21, 2019.

  1. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    Hi,

    I was experimenting with Cloth. I wanted to control fixed end points so that I'd be able to move it around like a blanket, carpet, whatever.

    Here's the code.

    Code (CSharp):
    1. public class ClothControl : MonoBehaviour
    2. {
    3.     public SkinnedMeshRenderer renderer;
    4.  
    5.     public Vector3[] vertices;
    6.  
    7.     public Transform controlPoint1;
    8.     public Transform controlPoint2;
    9.  
    10.     private void Update()
    11.     {
    12.         vertices = renderer.sharedMesh.vertices;
    13.  
    14.         vertices[0] = transform.InverseTransformPoint(controlPoint1.position);
    15.         vertices[10] = transform.InverseTransformPoint(controlPoint2.position);
    16.  
    17.         renderer.sharedMesh.vertices = vertices;
    18.     }
    19. }
    And guess what, after messing around with it in Play mode (it worked!), the Plane mesh is now completely messed up, in the entire project. There's not even a mesh property in the SkinnedMeshRenderer that I could have used.

    I mean, come the f on! That shouldn't be able to happen. If I mess with a mesh in Play mode, this should not ever at all affect the project assets. And it should never ever affect the Default assets.
     
  2. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    Reloading the project fixed the mesh. But this is annoying nonetheless.