public static Texture2D GenerateThumb(AutoTileset autoTileset, SlotAon slotAON) { int x = Mathf.RoundToInt(slotAON.AtlasRecThumb.x); int y = Mathf.RoundToInt(slotAON.AtlasRecThumb.y); int w = Mathf.RoundToInt(slotAON.AtlasRecThumb.width); int h = Mathf.RoundToInt(slotAON.AtlasRecThumb.height); Texture2D tilesetTexture = new Texture2D(w, h, TextureFormat.ARGB32, false); tilesetTexture.filterMode = FilterMode.Point; // Color[] autotileColors = autoTileset.PixelsThumb( slotAON).GetPixels(x, y, w, h); Color[] autotileColors = autoTileset.PixelsThumb(slotAON); tilesetTexture.SetPixels(autotileColors); tilesetTexture.Apply(); return(tilesetTexture); }
private static void _FillSpritesFromRect(List <Rect> _outList, AutoTileset autoTileset, int x, int y, int width, int height) { Rect srcRect = new Rect(0, 0, autoTileset.TileWidth, autoTileset.TileHeight); for (srcRect.y = height - autoTileset.TileHeight; srcRect.y >= 0; srcRect.y -= autoTileset.TileHeight) { for (srcRect.x = 0; srcRect.x < width; srcRect.x += autoTileset.TileWidth) { Rect sprRect = srcRect; sprRect.x += x; sprRect.y += y; _outList.Add(sprRect); } } }