- Home /
Changing vertex colors and mesh leak fix
Hi, i have a working script that alters the color of a cube using a script and a shader that allows changes in vertex colors but i'm getting this error:
Instantiating mesh due to calling MeshFilter.mesh during edit mode. This will leak meshes. Please use MeshFilter.sharedMesh instead.
Mostly from this line:
mesh = this.GetComponent(MeshFilter).mesh;
This can't be done because using you need a new mesh to have random vertex colors?
Is there a simple way to fix the mesh leak or another way to go about this, it slows down the editor on occasions and don't know if this slows down the game at all? any help?
You cannot use shared$$anonymous$$esh? Then you are going to have to Instantiate() a copy.
i did give it a go at Instantiate but didn't really work because forgot to mention, this is in edit mode; i'm using similar script to what the unity reference gives for $$anonymous$$esh.colors.
Shared$$anonymous$$esh = same vertices, same vertices = same colors so no.