Search Unity

[RELEASED] Super Tilemap Editor

Discussion in 'Assets and Asset Store' started by CreativeSpore, Feb 21, 2016.

  1. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    943
    jeanpoolay likes this.
  2. hublard

    hublard

    Joined:
    Aug 19, 2015
    Posts:
    79
    Anyone alreay figured out how to see Preview of a Prefab before place it in realtime like it is in Editor mode?
    It would be helpfull when a Player can see the Prefab preview. In my Game i place items at mouseposition when clicking on it.
     
    Last edited: Feb 14, 2019
  3. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Maybe you can use TilemapUtils.CreateTilemapGroupPreviewTexture to create a texture of the tilemap, create an sprite with that texture and use SpriteMask.
    But I am not sure how you are trying to get access to the tile pixels. Could you post your code?
     
  4. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    The carpet brush is splitting the tiles in 4 to create different combinations using less tiles in the tile palette.
    You can achieve the same as Rule Tile creating your own TilesetBrush. Use the RoadBrush as template and add more combinations depending on the neighbors to achieve the same.
    You have also a more complex brush you could have a look: the BrushFortySeven.
     
  5. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You can check the BrushBehaviour script. It is used to manage the editor preview brush. Basically it is a tilemap that is updated when you change the tileset selection of tiles.
     
  6. roleyzhang

    roleyzhang

    Joined:
    Nov 11, 2018
    Posts:
    4
    Hi @CreativeSpore,
    I just bought "Super Tilemap Editor" and I'm having trouble with how to set Tile data at an stetilemap from script, and I hope you can help me to fix the problem.

    I tried to draw the road on the Tilemap using code, based on the description of the document https://creativespore.com/2017/10/23/editing-tiles-of-an-stetilemap-from-script/

    First I created a tilemap Group that contains a ground and road. Also created a road brush.
    The brush id =1
    And then I tried to draw the road in the code.
    Code (CSharp):
    1.  STETilemap roadObject = road.GetComponent<STETilemap> ();
    2. var x = (int) buildingPlaceCursor.transform.position.x;
    3. var y = (int) buildingPlaceCursor.transform.position.y;
    4. roadObject.SetTile(x, y, -1, 1);
    5. roadObject.UpdateMeshImmediate ();
    The above code is called by the update () function, But there's no road on the map, drawn according to coordinates. I don't know what went wrong, and I hope to get your help. Thank you so much!
     

    Attached Files:

    • 1.png
      1.png
      File size:
      86.5 KB
      Views:
      726
  7. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    You can set a tile in a world position or a grid position.

    But if you use a world position, you need to use a vector2.
    Like:
    roadObject.SetTile(buildingPlaceCursor.transform.position, -1, 1);

    When you use integers, you are telling to place the tile at a cell position, so you have to multiply the value to the cell size.
     
  8. roleyzhang

    roleyzhang

    Joined:
    Nov 11, 2018
    Posts:
    4
    Thank you so much! I used your solution that fixed my issue.
     
    CreativeSpore likes this.
  9. uweenukr

    uweenukr

    Joined:
    Jan 17, 2011
    Posts:
    54
    Just bought the asset and had a couple questions I could not find answers for in the demo or documentation.

    1. When using Tiled Importer. Is it possible to prevent the duplication or tilesheet images? If I already have the tileset image in my Unity project and use it for Map1. It creates a second copy of that tilesheet. Now if I use that same tileset in Map2 now I have three copies of the same image. If the source in the tmx file is the correct path to the .tsx then its reference to the image source should also work right?

    desert.tmx:
    <tileset firstgid="1" source="desert.tsx"/>

    desert.tsx:
    <image source="tmw_desert_spacing.png" width="265" height="199"/>


    2. Do you only support TileProperties? Tiled Editor also has Map and Layer properties. When I create a TMX with those it silently fails to be imported. Also do you support importing tile properties straight from the TSX? I tried this modification and I was not able to auto import it:

    <tile id="47" terrain="0,0,0,0" probability="0.01">
    <properties>
    <property name="tileProperty" value="test2"/>
    </properties>
    </tile>


    3. When I make changes to a TMX file in the Tiled Editor it seems like the only way I can get the changes into Unity is to delete the whole Tilemap and reimport it via the 'Import TMX into the scene'. Am I doing something wrong? I initially expected the TileMap Group > Map > Refresh Map button to do that.

    I opened an issue with Tiled about XML missing when creating a new map. The owner said XML is depreciated.

    Thank you.
     
    Last edited: Feb 28, 2019
  10. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    I am having a weird error. I am making a dungeon crawler, and because I want nav mesh, doing fake 2D, so using 3D objects with sprites floating above them, for nav mesh and collision detection. Super Tilemap editor works great, until I turned my tilemap into a prefab. Once I did that, if I try and use the eraser on the tilemap in the main scene view, it gives me an error:


    InvalidOperationException: Destroying a GameObject inside a Prefab instance is not allowed.
    UnityEditor.Undo.DestroyObjectImmediate (UnityEngine.Object objectToUndo) (at C:/buildslave/unity/build/Editor/Mono/Undo/Undo.bindings.cs:74)
    CreativeSpore.SuperTilemapEditor.TilemapChunk.DestroyTileObject (UnityEngine.GameObject obj) (at Assets/CreativeSpore/SuperTilemapEditor/Scripts/Tilemap/TilemapChunk_TileObjFactory.cs:219)
    CreativeSpore.SuperTilemapEditor.TilemapChunk.FillMeshData () (at Assets/CreativeSpore/SuperTilemapEditor/Scripts/Tilemap/TilemapChunk_Renderer.cs:487)
    CreativeSpore.SuperTilemapEditor.TilemapChunk.UpdateMesh () (at Assets/CreativeSpore/SuperTilemapEditor/Scripts/Tilemap/TilemapChunk_Renderer.cs:153)
    CreativeSpore.SuperTilemapEditor.STETilemap.UpdateMeshImmediate () (at Assets/CreativeSpore/SuperTilemapEditor/Scripts/Tilemap/STETilemap.cs:1124)
    CreativeSpore.SuperTilemapEditor.STETilemap.Update () (at Assets/CreativeSpore/SuperTilemapEditor/Scripts/Tilemap/STETilemap.cs:432)


    This error also happens if I go inside the tilemap prefab, although it will delete the tile, but also give the error.

    Furthermore, if I go inside the tilemap prefab to edit the tiles, none of my tiles show up as a brush in the editor window, but you can see them still floating around in the game window and if I click they do paint. Very strange.

    I am using Unity 2018.3.4f and it seems Super Tilemap editor is struggling to adapt to the nested prefabs, or at least in this version it is.

    Is there a fix for this or anything? Hard to build a dungeon crawler with my hands tied like this.

    Thanks! Otherwise an amazing piece of software / tool.

    Edit: it is actually Unity 2018.3.4f1 if that makes much difference
     
    Last edited: Mar 1, 2019
  11. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    The reason for that is the new prefab workflow.
    Now, you cannot modify any prefab children unless you are in prefab edit mode.
    Open the prefab in edit mode before modifying it.
     
  12. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Tile properties are not supported. As it says in the asset description, it only supports rectangular tiles and layers, but anything else like colliders, tile properties, etc.

    When it imports form Tiled, it creates an atlas with all tileset textures and creates a tile view per tileset to organize the tiles in the same layout you see in Tiled.
    If you don't modify the Tiled tilesets you can import the maps directly without importing the tileset again.
    You can see all the process in this video tutorial:
     
  13. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    Thanks for your reply but I probably gave you too much information at once. I was also getting errors deleting tiles in the prefab edit mode although today that seems to have gone away, I guess closing and opening Unity did the trick.

    However, the other error I am getting in the prefab edit mode, which has not gone away, is that when I select a tile as a brush, I cannot see the brush in the editor, but I can see it in the game window, although it highlights which grid cell I am currently over.

    upload_2019-3-4_15-10-40.png

    In the above image, my mouse is hovering over the square in the middle with a tile brush selected, but you cannot see the brush when trying to paint in prefab edit mode. As you can see it still highlights the correct grid square though, so I can paint, but a bit inconvenient. I'm guessing Unity has made some change that has affected this.
     
  14. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Thanks for reporting this issue. I am working on it and I think I will have a fix before next Monday.
    As soon as I have a patch prepared I will post it here before the next version is approved in the store.
     
  15. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Hi there,

    I think I've fixed all warnings and issues related with Unity 2018.3 new prefab system.
    Please, import the attache package and let me know if you find any more issues.
    About the brush not being painted in prefab mode, I still need to figure out how to display it. It is tricky as it was a temporary invisible gameObject used in the scene.
     

    Attached Files:

  16. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    95
    Hi @CreativeSpore

    Am I be able to increase tilemap mesh complexity for more precise vertex painting?
     
  17. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    There is no option for that I'm afraid. I am not sure if there could be a work around, if you modify the code, but I think it is not trivial to achieve.
     
  18. TimNedvyga

    TimNedvyga

    Joined:
    May 18, 2015
    Posts:
    95
    Could you add this feature? If not, could you help me where to start, where mesh generation happen?
     
  19. Paulo_Ferrato

    Paulo_Ferrato

    Joined:
    Nov 26, 2018
    Posts:
    4
    All I need is a cheap way to take the sprite of my tilemap in playtime. What i am doing now is: everytime my tilemap changes, I take pixel by pixel of my tiles and create a new Sprite with this. That's anything but cheap. If I could get the textures2D that you're creating or something like that, would be awesome...
    Sorry for the late answer and tanks for the help, btw.
    Keep the good work!

    (That's my code)

    Code (CSharp):
    1.  
    2. public class TextureMaker
    3. {
    4.     private int CELLSIZE;
    5.     private Texture2D testTex;
    6.     private Color[] PIXELS;
    7.  
    8.     Dictionary<int, int> PosX = new Dictionary<int, int>();
    9.     Dictionary<int, int> PosY = new Dictionary<int, int>();
    10.  
    11.     public TextureMaker(int MinPosX, int MaxPosX, int MinPosY, int MaxPosY, int CellSize)
    12.     {
    13.  
    14.         List<float> lengthX = new List<float>();
    15.         List<float> lengthY = new List<float>();
    16.  
    17.         for (int x = (int)MinPosX; x <= MaxPosX; x++)
    18.         {
    19.             lengthX.Add(x);
    20.         }
    21.         for (int i = 0; i < lengthX.Count; i++)
    22.         {
    23.             PosX.Add((int)lengthX[i], i);
    24.         }
    25.  
    26.  
    27.         for (int y = (int)MinPosY; y <= MaxPosY; y++)
    28.         {
    29.             lengthY.Add(y);
    30.         }
    31.         for (int i = 0; i < lengthY.Count; i++)
    32.         {
    33.             PosY.Add((int)lengthY[i], i);
    34.         }
    35.  
    36.  
    37.         CELLSIZE = CellSize;
    38.  
    39.         testTex = new Texture2D((lengthX.Count) * CellSize, (lengthY.Count) * CellSize);
    40.  
    41.         //PIXELS BEM DEFINIDOS?
    42.         testTex.wrapMode = TextureWrapMode.Clamp;
    43.         testTex.filterMode = FilterMode.Point;
    44.  
    45.  
    46.         PIXELS = new Color[testTex.width * testTex.height];
    47.  
    48.     }
    49.  
    50.     #region GET/SET
    51.     public float GetWidth()
    52.     {
    53.         return testTex.width;
    54.     }
    55.  
    56.     public float GetHeight()
    57.     {
    58.         return testTex.height;
    59.     }
    60.  
    61.     public int GetCellSize()
    62.     {
    63.         return CELLSIZE;
    64.     }
    65.  
    66.     public Sprite GetSprite()
    67.     {
    68.      
    69.         Sprite newSprite = Sprite.Create(testTex, new Rect(0, 0, testTex.width, testTex.height), new Vector2(0, 0));
    70.         return newSprite;
    71.     }
    72.     #endregion
    73.  
    74.     public Sprite TestTile(Sprite sprite)
    75.     {
    76.        
    77.  
    78.         Color[] newPixels = sprite.texture.GetPixels((int)sprite.textureRect.x,
    79.                                                 (int)sprite.textureRect.y,
    80.                                               (int)sprite.textureRect.width,
    81.                                                (int)sprite.textureRect.height);
    82.  
    83.         Texture2D texture = new Texture2D((int)sprite.textureRect.width, (int)sprite.textureRect.height);
    84.         texture.wrapMode = TextureWrapMode.Clamp;
    85.         texture.filterMode = FilterMode.Point;
    86.         texture.SetPixels(newPixels);
    87.  
    88.         Sprite newSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
    89.         return newSprite;
    90.  
    91.     }
    92.  
    93.  
    94.     public void AddTile(int TileX, int TileY, Sprite sprite)
    95.     {
    96.         float rectX = sprite.textureRect.x;
    97.         int spriteX = (int)(rectX -= (sprite.textureRect.x % CELLSIZE));
    98.  
    99.         float rectY = sprite.textureRect.y;
    100.         int spriteY = (int)(rectY -= (sprite.textureRect.y % CELLSIZE));
    101.  
    102.  
    103.  
    104.         Color[] newPixels = sprite.texture.GetPixels(spriteX,
    105.                                                 spriteY,
    106.                                                CELLSIZE,
    107.                                                CELLSIZE);
    108.  
    109.         #region DEBUG
    110.         /*
    111.         Debug.Log("TileRect:" + spriteX + ", " + spriteY);
    112.  
    113.         Debug.Log("Size: " + sprite.rect.width + "p x " + sprite.rect.height + "p = " + (sprite.rect.width * sprite.rect.height) + "p : " + newPixels.Length);
    114.  
    115.         Debug.Log("Pixel: " + ((TileX * CELLSIZE)) + " to " + (((TileX + 1) * CELLSIZE)) + "x / " + ((TileY * CELLSIZE)) + " to " + (((TileY + 1) * CELLSIZE)) + "y");
    116.         */
    117.         #endregion
    118.  
    119.  
    120.  
    121.  
    122.         for (int x = 0; x < (newPixels.Length / sprite.rect.width); x++)
    123.         {
    124.             for (int y = 0; y < (newPixels.Length / sprite.rect.height); y++)
    125.             {
    126.                 PIXELS[
    127.                         ((PosY[TileY] * CELLSIZE) * testTex.width) +    //TOTAL DE LINHAS DE ACORDO COM O TileY
    128.                         (y * testTex.width) +                           //LINHAS JÁ ADICIONADAS
    129.                         (PosX[TileX] * CELLSIZE) +                      //TOTAL DE CASAS DE ACORDO COM O TileX
    130.                         x                                               //TOTAL DE CASAS JÁ ADICIONADAS
    131.                         ] =
    132.                        newPixels
    133.                        [(int)(y * sprite.rect.width) + x];       //ATUAL POSIÇÃO X E Y DENTRO DO TILE
    134.             }
    135.         }
    136.  
    137.         testTex.SetPixels(PIXELS);
    138.         testTex.Apply();
    139.  
    140.     }
    141.  
    142.     public void FillWithRed()
    143.     {
    144.         for (int i = 0; i < testTex.width * testTex.height; i++)
    145.         {
    146.             PIXELS[i] = Color.red;
    147.         }
    148.  
    149.         testTex.SetPixels(PIXELS);
    150.         testTex.Apply();
    151.     }
    152.  
    153.  
    154. }
     
  20. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    I just tried the patch. So far I can't see the warnings repeating when erasing tiles inside editor mode. The invisible brush is still a thing, though.

    It seems like you updated the actual inspector view as well at some point? So that now brushes can be selected from the inspector? Or did I simply not notice that before? I remember using a separate brush window. It's convenient nonetheless.
     
  21. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    I've upgraded to Unity 2018.3.8f1 and my tilemap is completely invisible in the scene view and the tools don't work. In play mode the maps work perfectly. I tried looking through this thread and applying some of the patches without much luck. Any help would be appreciated. Thanks!
     
  22. hublard

    hublard

    Joined:
    Aug 19, 2015
    Posts:
    79
    i checked the script, but there are many stuff and i dont find de right function for showing the preview in the editor.

    i dont know if its working with my idea but i wrote my own script for building stuff like:

    Code (CSharp):
    1. //select tile
    2. public void Click_TileId360() // Table1
    3.     {
    4.         TileId = 360;
    5.     }
    6.  
    7.  
    8. // place tile
    9. if (Input.GetMouseButtonDown(0))
    10.         {
    11.             Vector3 _MousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    12.             _MousePosition.z = 0;
    13.             float _dist = Vector3.Distance(PLAYER.transform.position, _MousePosition);
    14.  
    15.             if (TileId == 360)
    16.             {
    17.                 CreateBuildSystemStuff(_MousePosition, 280, BuildCategory.DECO);
    18.             }
    19.         }
    at the moment where i select the tile i need to see the prefab preview at mouse position like it is in editor mode.
    but im stucked. worked now for over 2 weeks on that problem :/
     
  23. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    Hi, I have a weird problem, not sure if this is a known issue or not. It's to do with updating my tilesheet. I'm using Pyxel Edit to edit my sprites. As I've been making new sprites, I've kept the horizontal width of the sprite sheet the same, and the size of tiles, but gradually increasing the size of the sprite sheet vertically as I add new sprites.

    Just today I added some new sprites, making the sprite sheet taller, and tried to update the tilesheet in the game, since the recent patch / update to Super Tilemap Editor. It has moved all of the sprites in my tilemaps and also the tile palette. I did move some sprites in the tilesheet, but not any that have been used in tilemaps.

    Here is an example of what it looks like after importing the new tilesheet.

    upload_2019-3-15_14-45-27.png

    Because the sheet increased in vertical height, I made sure to reslice it with Unity's sprite slicer. The door on the left is what happens if I drag the sprite out of the spritesheet from Unity. On the right is how Super Tilemap editor is now interpreting it - it's moved everything out of alignment, in this case 1 pixel but more in other cases, despite the fact that it's sliced correctly in Unity.

    The tile palette now looks like this:

    upload_2019-3-15_14-46-59.png

    And the tilemap now looks like this:
    upload_2019-3-15_14-47-26.png


    Instead of this:

    upload_2019-3-15_14-48-8.png

    Have I done something wrong importing? Is this a bug? I'm sure I've followed this exact same process before the Super Tilemap update without any bugs like this previously.

    Thanks
     
  24. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    Just to add to my previous post, the tile palette looked like this previously:

    upload_2019-3-15_14-52-38.png

    the ones with lots of dark grey around them are prefabs using 3D objects with a sprite floating over the top.
     
  25. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    To add further to the previous post, I went back to the 'Tileset' object and clicked a few things, namely 'Slice Atlas' and Optimize Atlas' and it seemed to fix the tile palette.

    upload_2019-3-15_15-3-12.png

    However, the tilemap still looked weird. Closing and re-opening seemed to align some of them correctly, but some are still out:

    upload_2019-3-15_15-4-28.png

    And goodness knows why updating the tilesheet increased the size of my tilemap by 1 around each edge. Although, going into the prefab editor, I see this:

    upload_2019-3-15_15-5-30.png

    The white is the 3D cubes I had beneath the sprites. It's white because they are supposed to be rotated 90 degrees (to work with 2D view and tilemaps painting correctly), but now they aren't.

    I have also noticed that reslicing the tilemap has removed the prefabs I was using as brushing in my tileset, and I think that somehow has stuffed up the prefabs I made. Some are rotated 90, some aren't, it's very weird. And when I go into the prefabs to edit them, I get that error again about "not being able to destroy prefabs", possibly because they are still being used as tiles in the tilemap, and yet aren't in the tileset.

    The short version is it looks like I'll need to redo my tilemap and tileset unless some fix comes.
     
  26. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    A further thing has happened.. I just deleted all of the tiles within the tilemap, then started to repaint - when going back out of the prefab view into scene view, many times what I just painted disappears, sometimes it doesnt' disappear. Definitely some weird bugs going on. Seems like nested prefabs are making things very tricky.

    Edit: and just to protect myself I added 6 empty rows of tiles vertically to the tilesheet in Pyxel Edit before exporting. Lo and behold the error happened again, reslicing it in the tileset object fixed the alignment, but there definitely seems to be a bug.

    Edit 2: Editing the tilesheet without increasing size does not seem to reproduce the error.

    Edit 3: I had that "base room" which was the tilemap with all of the castle walls set up as a prefab. After I fixed all of the tiles and prefabs up again and put them back into the tileset, the prefab magically went back to normal, including the tilemap went back to its original size. Very confused right now about what actually happened lol
     
    Last edited: Mar 15, 2019
  27. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I have just updated Super Tilemap Editor to v1.6.1
    It have some fixes for new prefab workflow.
    Did you try the last version?
     
  28. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    After updating the tileset Atlas texture size you also need to refresh all the tilemaps to fix the tile UVs with the new size.
    You can do that in the Map section:
    upload_2019-3-16_21-7-16.png
     
  29. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    @CreativeSpore Yes I'm on the latest version 1.6.1. My map is not in a prefab. Creating a brand new tilemap in the scene allows it to work, but the existing one doesn't. Making it a prefab, deleting it, and re-placing it in the scene did not fix the issue.

    OK I just tried something. I loaded a different scene and some of the other maps do work. In fact it appears that 2 of my 18 tilesets have this issue, where none of the others do. Creating new tilemaps from those tilesets do seem to work though, just not the old maps.
     
  30. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    Yeah that's the version I've been using.
     
  31. GameDevSA

    GameDevSA

    Joined:
    Dec 12, 2016
    Posts:
    252
    Sadly that did not work. Just tried adding an empty row to the sprite sheet to test, updated in Unity, went into the prefab, updated the slicing in the tileset as well as the Unity default, optimized the atlas, refreshed the map (which maybe should be an automated thing in case someone missed it like me or made very clear somewhere), but it still was misaligned after.

    upload_2019-3-18_15-58-18.png

    But to be honest I don't feel like the issue is a button press somewhere. I'm pretty sure whenever I changed the size of my atlas before, vertically, I never had any of these issues - prior to nested prefabs and Unity 2018.3.4f1. Any chance I should update Unity to the next version which literally just came out? Although my experience is that often makes things worse lol
     

    Attached Files:

  32. zh4r0naX

    zh4r0naX

    Joined:
    Oct 30, 2016
    Posts:
    71
    Is it possible that STE is making the new prefab system save over and over, when you got many tilemaps in new prefabs ? Because that is happening for me and is really annoying, just cant find the cause of this problem.

    Unity said that could happen when there is something which marks the scene dirty too often.

    Thank you
     
  33. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Did you try disabling the AutoSave check box? I think that could be the cause:
    upload_2019-3-20_19-36-38.png
     
  34. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Be sure the height is including the tile size and the padding offset.
    The would be the steps to follow after changing the texture height. In this case it was 21+2=23 pixels:

    upload_2019-3-20_19-46-17.png

    upload_2019-3-20_19-46-36.png

    Also, check that your texture is not bigger than Max Size set in your import settings:
    upload_2019-3-20_19-47-27.png
     
  35. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    @CreativeSpore still waiting on some direction with this issue:

    TL;DR - Some of my existing maps are invisible in the scene view and the brush editor doesn't show up. Some of my maps work fine. Runtime works fine for all.

     
  36. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Could you send me a test project with a working tilemap and a broken one?
    What version of Unity are you using?
    I know the brush is not displayed in prefab edit mode even if you can paint with it.
    I am working on it.
     
  37. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    I am not using prefabs at all. I don't know how I'd make a test project since the same tileset works when I create a new map with it, but the existing one doesn't. Unity version is 2018.3.8f1
     
  38. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    I don't know how to reproduce this bug. It would help to have a test project were there is a tilemap that is not working to check what is making it to be invisible.

    By the way, I have fixed a performance issue in the current version. I don't think this would fix your issue, but just in case here it is.
     

    Attached Files:

  39. ury2ok2000

    ury2ok2000

    Joined:
    Dec 29, 2012
    Posts:
    46
    Great asset, I've been using it for quite some time. Quick question some of my prefab tiles for not show an image on the (I think it's ) palette box. Is there an easy way for me to set the image elsewhere? Or do I need to have the Sprite render be the first part of the prefab or something (currently the prefab has a parent object and the child objects contain the actual stuff for the asset). Thanks!
     
  40. ury2ok2000

    ury2ok2000

    Joined:
    Dec 29, 2012
    Posts:
    46
    Ok, I solved it- my tile map had no sprites over the 'tiles' that i was using for my pre-fab (and so they were blank). Putting an image in that spot then de-selecting show preb in palette allowed for me to see the image I wanted.
     
    CreativeSpore likes this.
  41. hublard

    hublard

    Joined:
    Aug 19, 2015
    Posts:
    79
    Hello,

    maybe someone can help me out.

    to get data at what location the tile is i use:
    Debug.Log("X" + TilemapUtils.GetMouseGridX(PlayerCreation.InstanceObj.GroundTemplate, Camera.main));
    Debug.Log("Y" + TilemapUtils.GetMouseGridY(PlayerCreation.InstanceObj.ObjectTemplate, Camera.main));


    but how can i place an tile at exactly this position? when i use:

    Vector3 _MousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    CreateBuildSystemStuff(_MousePosition, 335, BuildCategory.PLOT);

    it will place the tile at this location but not exactly with same values.

    For example:
    i get tiledata with this command
    Debug.Log("X" + TilemapUtils.GetMouseGridX(PlayerCreation.InstanceObj.GroundTemplate, Camera.main));
    Debug.Log("Y" + TilemapUtils.GetMouseGridY(PlayerCreation.InstanceObj.ObjectTemplate, Camera.main));

    it will give me for
    X: 10
    Y: 20

    with the following command i will place the tile there

    Vector3 _MousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    CreateBuildSystemStuff(_MousePosition, 335, BuildCategory.PLOT);

    but dependent where exactly i click the tiledata are
    X 10.54
    Y 20.12

    how can i place the a Tile exactly at the location like i get tiledata in the first command instead of mouseposition?
     
  42. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Use this code snippet:
    Code (CSharp):
    1.  
    2. TilemapUtils.GetTileCenterPosition(tilemap, gridX, gridY);
    3.  
    Don't confuse grid positions and world positions. They are not the same.
    The gird position is the position is cells or tiles from the tilemap center.
    The world position is a position in Unity units, like the position of the transform.position of a gameObject.

    For each method you always have two versions, one for grid coordinates and another for world units.
     
  43. Mijago

    Mijago

    Joined:
    Mar 27, 2016
    Posts:
    11
    Hello @CreativeSpore .

    For convenience we wanted to create the following structure:
    * Most of our game runs in one scene
    * Every SpaceShip is it's own prefab
    * Every deck of every SpaceShip is a new prefab itself (-> we use prefab nesting)

    This should allow us to work on the same SpaceShip (on different layers) at the same time, without taking turns because the GameScene would be occupied and VCS could destroy it on merge.

    I also ran into a problem with a short lag after every tile I placed, but you already gave the solution here:
    But why I write this post: Whenever I edit a tilemap in the prefab, the GameScene (which contains the instantiated prefab) receives some updates. It seems to work fine when I simply revert the changes in the GameScene.

    But is it safe to revert the changes?
    Why are there changes in the GameScene after saving the modified tilemap-prefab?

    We are still investigating the changes, but maybe you can help us out here.
     
  44. hublard

    hublard

    Joined:
    Aug 19, 2015
    Posts:
    79

    okey thank you, but i have a Question
    Code (CSharp):
    1.  
    2. TilemapUtils.GetTileCenterPosition(tilemap, gridX, gridY);
    3.  
    what shoud i use for gridX and gridY. i Need to check what tileid of a specific tilepalete is at mouse Position.
    dont know how to find out with the upper command.

     
  45. Mijago

    Mijago

    Joined:
    Mar 27, 2016
    Posts:
    11
    @CreativeSpore

    I have a fix for the problem that the brush-preview in prefabs is not visible.
    The problem is that the brush is on the wrong scene - the world scene, not the prefab scene.

    The fix is fairly simple: Move the brush to the scene of the tilemap. Another way would be fetching the prefab scene, checking if it exists and then setting it to the brush.

    File: TilemapEditor.cs, Line ~800, after the line "// Update brush transform"
    Just insert this before the dragging check:
    Code (CSharp):
    1.  
    2. if (brush.gameObject.scene != m_tilemap.gameObject.scene)
    3.     SceneManager.MoveGameObjectToScene(brush.gameObject, m_tilemap.gameObject.scene);
    4.  
    Of course one could also add it to the BrushBehaviour.GetOrCreateBrush function.
     
    Last edited: Apr 20, 2019
    CreativeSpore likes this.
  46. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    In that case you can use this code:
    Code (CSharp):
    1.  
    2. int gx = TilemapUtils.GetMouseGridX(tilemap, camera);
    3. int gy = TilemapUtils.GetMouseGridY(tilemap, camera);
    4. uint tileData = tilemap.GetTileData(gx, gy);
    5.  
    This code will also find the first visible tile in a tilemap group:
    Code (CSharp):
    1.  
    2. public static uint FindFirstVisibleTileByMouse(TilemapGroup tilemapGroup, Camera camera, out STETilemap tilemap)
    3. {
    4.     STETilemap[] sortedTilemaps = tilemapGroup.Tilemaps.OrderBy(o => o.SortOrder).ToArray();
    5.     for (int i = 0; i < sortedTilemaps.Length; i++)
    6.     {
    7.         tilemap = sortedTilemaps[i];
    8.         int gx = TilemapUtils.GetMouseGridX(tilemap, camera);
    9.         int gy = TilemapUtils.GetMouseGridY(tilemap, camera);
    10.         uint tileData = tilemap.GetTileData(gx, gy);
    11.         if (tileData != Tileset.k_TileData_Empty)
    12.         {
    13.             return tileData;
    14.         }
    15.     }
    16.     tilemap = tilemapGroup.SelectedTilemap;
    17.     return Tileset.k_TileData_Empty;
    18. }
    19.  
     
  47. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    Thanks for posting a bug solution and for the time you spent on this ;)
    I will check the code to see other references to the same check.
    This fix will be included in the next update.
     
  48. MaximovInk

    MaximovInk

    Joined:
    Oct 17, 2016
    Posts:
    11
    [removed links] STE source code. Is this a violation?
     
    Last edited by a moderator: Apr 29, 2019
  49. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    943
    @MaximovInk Yes it is. Please edit your message to remove the links.
     
  50. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,192
    @MaximovInk Please, remove the links. Thanks for the warning but a PM would have been better than posting the links.