Beispiel #1
0
 public void RefreshBrushGizmoFromTileset(int tileset, int high = -2)
 {
     BrushAction = new TileAction();
     if (tileset >= -1)
     {
         if (MyAutoTileMap.Tileset.IsExitSlot(tileset))
         {
             SlotAon slot     = MyAutoTileMap.Tileset.GetSlot(tileset);
             int     selTileW = (int)slot.Size.x;
             int     selTileH = (int)slot.Size.y;
             for (int j = 0; j < selTileH; ++j)
             {
                 for (int i = 0; i < selTileW; ++i)
                 {
                     BrushAction.Push(MyAutoTileMap, i, j, tileset, slot.LayerDraw, -2);
                 }
             }
         }
         else
         {
             BrushAction.Push(MyAutoTileMap, 0, 0, tileset, 0, -2);
         }
     }
     else
     {
         BrushAction.Push(MyAutoTileMap, 0, 0, -2, 0, high);
     }
     RefreshSpriteRenderers();
 }
Beispiel #2
0
 private void SetSpriteRendererSlot(SpriteRenderer spriteRender, SlotAon slot, Vector2 pivot)
 {
     if (slot != null)
     {
         // slot.AtlasRecThumb;
         spriteRender.sprite = Sprite.Create(MyAutoTileMap.Tileset.TextureSlot, slot.AtlasRecThumb, pivot, AutoTileset.PixelToUnits);
         // spriteRender.color = new Color32( 255, 255, 255, 160);
         spriteRender.color = new Color32(255, 255, 255, 192);
     }
 }
 public Color[] PixelsThumb(SlotAon slot)
 {
     if (slot.TypeLayer == eSlotAonTypeLayer.Ground)
     {
         if (slot.idRef >= 0 && slot.idRef < DrawTileAonSetSelected.DrawTileAons.Count)
         {
             DrawTileAon d = DrawTileAonSetSelected.DrawTileAons[slot.idRef];
             return(DrawTileAonSetSelected.TextureThumb.GetPixels(d.xBegin, d.yBegin - 32, 32, 32));
         }
     }
     return(TextureSlot.GetPixels(Mathf.RoundToInt(slot.AtlasRecThumb.x), Mathf.RoundToInt(slot.AtlasRecThumb.y), Mathf.RoundToInt(slot.AtlasRecThumb.width), Mathf.RoundToInt(slot.AtlasRecThumb.height)));
 }
        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);
        }