public void OnMouseUp(RagePixelState state) { Sprite sprite = state.Sprite; Color[] pixels = Utility.GetPixels(sprite); int originalWidth = (int)sprite.textureRect.width; int originalHeight = (int)sprite.textureRect.height; Texture2D texture = sprite.texture; int width = _size.x; int height = _size.y; texture.Resize(width, height, texture.format, texture.mipmapCount > 0); texture.SetPixels32(Utility.GetDefaultPixels(texture.width, texture.height)); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (x < originalWidth && y < originalHeight) { texture.SetPixel(x, y, pixels [y * originalWidth + x]); } } } texture.Apply(); Utility.SaveImageData(sprite, true); ShiftTransformAfterResize(state.Transform, sprite, originalWidth, originalHeight, width, height); SceneView.RepaintAll(); }
public void SaveSnapshot(Sprite sprite) { _mSnapshot = Utility.GetPixels(sprite); }