I’m creating a sprite in c# like this:
Texture2D t = new Texture2D(2,2);
t.LoadImage(bytesFile.bytes);
t.filterMode = filterMode;
t.wrapMode = textureWrapMode;
t.alphaIsTransparency = alphaIsTransparency;
t.anisoLevel = anisoLevel;
t.hideFlags = HideFlags.DontSave;
Sprite s = Sprite.Create(t, new Rect(0,0, t.width, t.height),
v2, pixelsToUnits);
s.hideFlags = HideFlags.DontSave;
GetComponent<SpriteRenderer>().sprite = s;
And that works fine, but the editor complains after a while that the sprite and texture are being leaked:
“Sprite has been leaked 1 times” etc
How do I stop leaking?