public static Texture2D Crop(this Texture2D tex) { int w; int h; var array = tex.GetColorSafe(out w, out h); return(tex.BlitCrop(CropHorizontalVertical(array, w, h))); }
public static Texture2D Crop(this Texture2D tex) { int w; int h; var array = tex.GetColorSafe(out w, out h); var rect = CropHorizontalVertical(array, w, h); if (rect == Rect.zero) { throw new ArgumentException("Texture2D has no pixels with alpha >= " + alphaThreshold, "tex"); } return(tex.BlitCrop(rect)); }