I’m trying to modify a sprite’s geometry but whatever parameters I set, OverrideGeometry always throws this exception:
Invalid vertex array. Some vertices are outside of the Sprite rectangle: (1358.000000, 579.000000).
UnityEngine.Sprite:OverrideGeometry(Vector2[ ], UInt16[ ])
To discard any errors on my algorithm, I modified it to make an exact copy of the original vertices and rectangle size, but even coping the original values causes the exception to be thrown.
I did some research and found out this bug was found on Unity 2017.2.0p2,and it was reported to be fixed on 2018.2… however I’m using 2019.2, and still experiencing the same problem.
However… the problem is that you need to handle two different metrics, this is a problem not because you need to do some calculations to make this function work, but because you if you do a simple A=B and then B=A you get an error, and that should not happen. The value returned by Sprite.vertices gives you world units while OverrideGeometry requires pixels. That inconsistency can be the source for lots frustration, complaints and errors.