Weird issue with GetComponent().sharedMesh.uv
I'm using the following code to flip the UV on the backside of a cube:
Vector2[] uvs = GetComponent().sharedMesh.uv;
uvs[7] = new Vector2(0, 0);
uvs[6] = new Vector2(1, 0);
uvs[11] = new Vector2(0, 1);
uvs[10] = new Vector2(1, 1);
GetComponent().sharedMesh.uv = uvs;
It flips the uv as expected, but if I comment out everything and hit play in unity editor, I see that the uv remains flipped (as if the code produced a permanent change to the uv).
If I close and reopen Unity editor, and then hit play, the uv is again in it initial (non flipped) status.
This is not really issue in this case, but it caused me many troubles during debug, can someone explain this behaviour?
Your answer
![](https://koobas.hobune.stream/wayback/20220612152825im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Editor Script Without GameObject 0 Answers
[Custom Inspector] How to keep a reference to a selecion in a drop down menu? 0 Answers
selecting prefab from project window with Editor script 1 Answer
Unity crashes whenever I try to modify a prefab 1 Answer
How to create a drop down menu in editor inspector 0 Answers