- Home /
 
how to remove vertices of a certain colour range from a mesh?
I have a cube with a texture. I want to delete all the remove all the vertices of a certain RGB colour range, retaining all the other vertices. I know similar questions have been asked before but they did'nt work in my case. any help?
               Comment
              
 
               
              Am going to be completely honest. I made this code a while ago and I don´t remember what was I doing, but it might help.
 Color[] color;
 Vector3[] vertices;
 Vector3 vertex;
 void Start ()
 {
     vertices = GetComponent<$$anonymous$$eshFilter>().mesh.vertices;
     color = GetComponent<$$anonymous$$eshFilter>().shared$$anonymous$$esh.colors;
 }
 
 void Update ()
 {
     for (int i = 0; i < vertices.Length; i++)
     {
            if (color[i] == Color.red)
            {
                vertex = vertices[i];
                //do whatever you need with vertex
                vertices[i] = vertex;
            }
     }
   
     this.GetComponent<$$anonymous$$eshFilter>().mesh.vertices = vertices; //I don´t remember the purpose of this, but it might be useful
 }
                 Your answer
 
             Follow this Question
Related Questions
Fast way to find vertex of spezific color 1 Answer
Color not appearing on created mesh? (only grey) 2 Answers
Changing Mesh Vertex Colors in editor 0 Answers
Change color of mesh triangle based on Y position in world space 1 Answer
Finding Viewport Coordinates of Vertices of Meshes that are in View 1 Answer