internal static Texture2D _copyTexturesIntoAtlas(Texture2D[] texToPack, int padding, Rect[] rs, int w, int h, MB3_TextureCombiner combiner) { Texture2D ta = new Texture2D(w, h, TextureFormat.ARGB32, true); MB_Utility.setSolidColor(ta, Color.clear); for (int i = 0; i < rs.Length; i++) { Rect r = rs[i]; Texture2D t = texToPack[i]; Texture2D tmpTex = null; int x = Mathf.RoundToInt(r.x * w); int y = Mathf.RoundToInt(r.y * h); int ww = Mathf.RoundToInt(r.width * w); int hh = Mathf.RoundToInt(r.height * h); if (t.width != ww && t.height != hh) { tmpTex = t = MB_Utility.resampleTexture(t, ww, hh); } ta.SetPixels(x, y, ww, hh, t.GetPixels()); if (tmpTex != null) { MB_Utility.Destroy(tmpTex); } } ta.Apply(); return(ta); }
internal Texture2D _resizeTexture(Texture2D t, int w, int h) { Texture2D tx = MB_Utility.resampleTexture(t, w, h); _temporaryTextures.Add(tx); return(tx); }
internal Texture2D _resizeTexture(string propertyName, Texture2D t, int w, int h) { Texture2D tx = MB_Utility.resampleTexture(t, w, h); tx.name = string.Format("tmpResampled{0}_{1}x{2}", _temporaryTextures.Count, w, h); TemporaryTexture txx = new TemporaryTexture(propertyName, tx); _temporaryTextures.Add(txx); return(tx); }