public static Texture2D SubTexture(Texture2D in_tex, RectP rectP) { Texture2D texture2D = new Texture2D(rectP.width, rectP.height); texture2D.SetPixels(in_tex.GetPixels(rectP.x, rectP.y, rectP.width, rectP.height)); texture2D.Apply(); return(texture2D); }
public static Texture2D SpriteSizeFix(Texture2D in_tex, RectP rectP, RectP border) { Texture2D texture2D = new Texture2D(border.width, border.height); texture2D.SetPixels(colors); texture2D.SetPixels(rectP.x, rectP.y, rectP.width, rectP.height, in_tex.GetPixels()); for (int i = 0; i < texture2D.width; i++) { for (int j = 0; j < texture2D.height; j++) { if (((i == rectP.xmin - 1 || i == rectP.xmax + 1) && (rectP.ymin - 1 <= j && j <= rectP.ymax + 1)) || ((rectP.xmin - 1 <= i && i <= rectP.xmax + 1) && (j == rectP.ymin - 1 || j == rectP.ymax + 1))) { texture2D.SetPixel(i, j, Color.red); } } } texture2D.Apply(); return(texture2D); }