Optimize GC for sprite update.

This commit is contained in:
2023-02-18 14:42:42 +08:00
parent ff8c925f32
commit ba6239068a
2 changed files with 15 additions and 16 deletions

View File

@@ -127,15 +127,15 @@ namespace Cryville.Crtr.Components {
UpdateScale();
UpdateZIndex();
}
readonly Vector2[] _uvs = new Vector2[4];
protected virtual void UpdateUV() {
var frame = CurrentFrame;
if (SpriteInfo.IsNullOrEmpty(frame)) return;
Vector2[] muv = OriginalUV;
Vector2[] uv = new Vector2[muv.Length];
for (int i = 0; i < uv.Length; i++) {
uv[i] = frame.Frame.GetUV(muv[i]);
for (int i = 0; i < _uvs.Length; i++) {
_uvs[i] = frame.Frame.GetUV(muv[i]);
}
mesh.Mesh.uv = uv;
mesh.Mesh.uv = _uvs;
}
float _opacity = 1;