Search Unity

Official Experiences with upgrading to Tilemap Editor Package in 2019.2

Discussion in '2D' started by ChuanXin, Jul 11, 2019.

?

Were there any issues when upgrading from your previous Unity project?

  1. Yes

    12 vote(s)
    54.5%
  2. No

    10 vote(s)
    45.5%
  1. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, in the recent 2019.2 beta, we have moved the Tile Palette and its related Editor Tooling features to a Unity package in Package Manager. This resulted in some changes which would affect upgrading existing Tilemap projects, for example: changes in the namespace from UnityEditor to UnityEditor.Tilemaps and the addition of a “Unity.2D.Tilemap.Editor” Assembly Definition.

    If you have tried out the Tilemap Editor package in 2019.2, were there any issues when upgrading from your previous Unity project? If there were major issues, could you post them here?

    Thanks!
     
  2. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    The changelog for 2019.2.0 mentions:
    2D: Users can now convert Prefabs to Tile Palettes by dragging a valid Prefab onto the Tile Palette window.

    I havent been able to make this work. Can gameobject prefabs be dragged in?
     
  3. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Currently, the GameObject prefabs that are dragged in should have a Grid and Tilemap Component for this to work.

    Could you describe the GameObject prefabs that you want to show up on the Tile Palette?
     
  4. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Ah I suppose I misunderstood the purpose of this feature. I thought that this meant that we can finally drag any prefab and make it into a tile (i.e. paint with prefabs and not sprites).

    Will this be supported in the near feature?
     
    Lars-Steenhoff likes this.
  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    There will be an update for the Tile Palette in the future so that you can place GameObjects and Instanced Prefabs on the Tile Palette. These will not be converted to Tiles on the Tile Palette. Handling of these GameObjects will require the use of the Prefab/GameObject Brush from 2d extras instead of the default Brush.

    The requirement of the dragging of GameObject Prefabs will still require a minimum of a Grid component (without the Tilemap component).
     
  6. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Ah I see, I think I've got it now:

    So currently, you can drag GameObject prefabs that have a Grid and Tilemap component into the palette, so that you can "paint" directly onto those prefabs (instead of drawing to a tilemap in the scene hierarchy).

    But as of right now, theres no way to have GameObjects as a tile itself in your palette that you can select and paint with. I have to use the Prefab Brush from 2d extras as it is for now?

    In the future update, you mention that we will be able to place GameObjects and Instanced Prefabs in the palette, but still need to use the GameObject brush. Will the brush automatically update its reference to the gameobject you have selected in the palette?

    Currently my problem with the 2d Extras prefab brush is that its so cumbersome to paint various prefabs. Either I have to create an entirely new brush for each prefab i want to paint, or i have to keep dragging in a new reference :(
     
  7. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Technically, it is possible to have a Tile with a GameObject set in it and place that Tile in the Tile Palette. The GameObject property is hidden in the Inspector for the Tile, but can be exposed through scripting or if the inspector is set in the Debug mode.

    Yes, using the Pick tool, the GameObject brush will pick the GameObjects in the selection in the Tile Palette and you will be able to paint with these GameObjects.

    The update in the future to the TilePalette with the GameObject brush will help with this!
     
    ShervinM likes this.
  8. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    Do the dragging of these GameObjects and Prefab Instances inside tile pallet area of tile pallets window require this objects to have a Grid component?

    This seems illogical to me. Becouse those objects will not be treated as tilemaps iNstead they will be placed at tilemaps.

    Because you said right after above quote.
     
    Last edited: Aug 11, 2019
  9. hlw

    hlw

    Joined:
    Aug 12, 2017
    Posts:
    250
    I guess that you might want to create a grid, populate it with one or multiple gameObjects as childs, drag and drop it in the tile palette, and by doing so, creating a palette populated with the gameObjects that were the childs of that grid, that will be ordered in that palette the same way they were in the grid prefab. (Not sure I understood that correctly, but that seems to be a pretty nice workflow to me)
     
  10. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The GameObject used as the Tile Palette will need to have a Grid component (and a Tilemap component currently). The GameObjects and the Prefabs you wish to place on the Tile Palette will not have these requirements.
     
    TextusGames likes this.
  11. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Yes, this will be the case.
     
  12. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    Finally it will happen. Thank you :)
     
  13. bloodwolftico

    bloodwolftico

    Joined:
    Nov 13, 2017
    Posts:
    100
    Hi there. I am using Tilemap but on Unity ver 2018.3.0f2. If I move to Unity's latest 2019 version, would this affect my current project negatively?
     
  14. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The thread was opened as the code for the Tile Palette has been moved to a Unity Package handled by the Package Manager instead of being embedded with the Unity Editor itself. This does change your project a little as you would now need to include the 2D Tilemap Editor package in your project if you are using it. Upgrading from 2018.3 to 2019.2 should automatically add it for you. Also, some of the namespaces for Tilemap related classes have changed which require a script update, where the Unity API updater will do its best to update your scripts. If you are using Assembly Definitions referencing the Tile Palette, you will need to add the new Tile Palette Assembly Definitions to your Assembly Definitions. None of your Tilemap data is affected with the upgrade.

    In short, we have tried to cover most of the cases you will have issues with upgrading automatically. I do not believe that your project will be affected negatively when upgrading from 2018.3 to 2019.2. However, if you do have problems, this thread is open and we will help you with your upgrading issues.
     
    bloodwolftico likes this.
  15. h765643729

    h765643729

    Joined:
    Jan 17, 2018
    Posts:
    21
    How can I use code to generate a Palette and import Tile to Palette?
     
  16. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hmmm, I believe that API for creating a palette is not public. I will change it so that it is public.

    Adding a Tile to an existing Palette in the Editor can be done by:
    Code (CSharp):
    1.  
    2. var palette = AssetDatabase.LoadAssetAtPath<GameObject>(path);
    3. var tile = AssetDatabase.LoadAssetAtPath<TileBase>(tilePath);
    4. var tilemap = palette.GetComponentInChildren<Tilemap>();
    5. tilemap.SetTile(position, tile);
    6. PrefabUtility.SaveAsPrefabAssetAndConnect(palette, path, InteractionMode.UserAction);
    7.  
    You will probably get better response if you ask this in the 2D forum, rather than in this thread, as this thread is more about Tilemap issues while upgrading to 2019.2.
     
    h765643729 likes this.
  17. h765643729

    h765643729

    Joined:
    Jan 17, 2018
    Posts:
    21
    Thank you, I saw in the forum that someone has asked the question, but no one answered, so I asked questions here. Sorry.
     
  18. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    Will tileMap could be editored in run-time in futher Unity versions?:D
     
  19. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    If you mean in game level editor, then I do not think so.
     
  20. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    (⊙o⊙)… Impossible or unvaluable?:(
     
  21. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    it is too game-specific. They just could not benefit each unique game. (at least in UI style)
     
  22. Bagazi

    Bagazi

    Joined:
    Apr 18, 2018
    Posts:
    611
    Maybe it is not about UI... I mean if level map using tiledMap could be editored in run-time,which is for players. Just like Mario does on Switch..
     
  23. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    For users to be able to edit in game levels there need to be some kind of user interface(UI). And the style of that UI is different for each game. It's is just one example. If style and positions of UI will be exactly the same then each unity game that uses this feature will be kind of affiliated with each other, but in fact they not.
    Of course they can provide us some place holder UI which we can modify. But knowing Unity team I think they will not bother about that feature.. This is my personal opinion though.
     
  24. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    You can add and remove Tiles in the Player on a Tilemap using the Tilemap APIs. But as TextusGames mentioned, there is no built-in user interface to do that in the Player (such as what you see with the Tile Palette in the Editor) since the choices of inputs, user interface styles and user experience would be up to you to decide.

    Would a template or example of this be useful to you?
     
    ShervinM and TextusGames like this.
  25. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Hi guys! I had another issue I was hoping someone could help with.

    I have a custom brush that subclasses from <<GridBrush>>.
    I have an editor script for this brush that inherits from <<GridBrushEditor>>.

    I obtain the SerializedProperty that represents a game object member variable like this:
    Code (CSharp):
    1. private SerializedProperty m_Parent;
    2. protected override void OnEnable()
    3. {
    4.     m_Parent = m_SerializedObject.FindProperty("m_Parent");
    5. }

    And then I display the field like this:
    Code (CSharp):
    1.  public override void OnPaintInspectorGUI()
    2. {
    3.      EditorGUILayout.PropertyField(m_Parent, true);
    4. }
    But unlike every other editor script I've made, this field won't accept a scene object reference. Any idea why? is this a limitation of OnPaintInspectorGUI?
     
  26. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    There should not be any difference between this and another editor script. Could you share what m_Parent on your brush is?

    The following works for GameObjects in the scene:

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.Tilemaps;
    3. using UnityEngine;
    4.  
    5. [CustomGridBrush(true, false, false, "Property Brush")]
    6. public class PropertyBrush : GridBrush
    7. {
    8.     [SerializeField]
    9.     private GameObject m_MyGameObject;
    10. }
    11.  
    12. [CustomEditor(typeof(PropertyBrush))]
    13. public class PropertyBrushEditor : GridBrushEditor
    14. {
    15.     private SerializedProperty m_MyGameObjectProperty;
    16.  
    17.     protected override void OnEnable()
    18.     {
    19.         base.OnEnable();
    20.         m_MyGameObjectProperty = serializedObject.FindProperty("m_MyGameObject");
    21.     }
    22.  
    23.     public override void OnPaintInspectorGUI()
    24.     {
    25.         serializedObject.Update();
    26.         EditorGUILayout.PropertyField(m_MyGameObjectProperty, true);
    27.         if (serializedObject.hasModifiedProperties)
    28.             serializedObject.ApplyModifiedProperties();
    29.     }
    30. }
    31.  
     
    ShervinM likes this.
  27. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Hi @ChuanXin,

    Boy do I have a bug/question for you. Looking to see if maybe you can help me out!

    So I spent the better part of yesterday updating our project over from 2019.1 to 2019.4.3. As part of that process, I noticed that many of my existing scenes where I had used the 2d Extras RuleTiles (where each rule has an associated gameobject) would look perfectly find at edit time, but at run time, many of the gameobjects associated with those rules tiles wont be instantiated. I use these rule tiles to generate walls and floors.

    Debugging a bit further, I noticed that on the first frame, the startup method of the rule tile passes along a null for the instantiated gameobject of many of these tiles, which would explain why I'm not seeing these objects at runtime.

    I've spent hours now trying to find a solid repro, and I think i finally have it, but I dont really understand if this is regression or intended behaviour.

    You see, one of my scripts was calling tilemap.CompressBounds() on start, and it looks like this method call is the culprit. I've attached a 2019.4.3 project with the 2d-extras listed in the packages manifest (latest version of the 2d-extras). Take a look the "SampleScene". In it I've drawn on tilemap a rectangle of rule tiles (each of which spawn a gameobject).

    Repro Project:
    https://drive.google.com/file/d/1PtsrhHzpa7VPjgFka6srdM6mwS4vD-zm/view?usp=sharing

    On the tilemap object, i have a "TilemapCompress" script component that simple makes a call to CompressBounds() on Start.

    Press Play with this component attached and see how at playmode the cubes disappear (or rather they simply dont instantiate).

    Remove this component and press play, and see how the cubes are there.

    Whats going on here?

    Best,
    Shervin
     
  28. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Sorry, this is a bug unfortunately. This has been fixed in 2020.1a14. We can try to backport this to a 2019.4 release!
     
  29. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Oh wow! Yeah this is pretty critical for our project. Is there anything i have to do (file an official bug report) in order to get it backported?

    Thanks so much for the quick response (as per usual) @ChuanXin, always appreciate your help :)
     
  30. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    No, you do not have to, since we can reproduce the issue with your example project above.

    I will post the Unity 2019.4 version here when the fix is backported successfully.
     
  31. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Hi @ChuanXin ,

    Do you have any idea on a timeframe we can expect for the 2019.4 LTS version that has this fix?

    I don't see any mention of it in fixes or currently known issues in any of the releases.

    Thanks!
     
  32. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Sorry for the delay, but interestingly, the fix finally landed around the time you posted this! This will come in 2019.4.8f1, which should be released next week.
     
    ShervinM likes this.
  33. ShervinM

    ShervinM

    Joined:
    Sep 16, 2017
    Posts:
    67
    Awesome! And no rush at all, was just merely curious so we could plan some work.

    Thanks so much for the follow up, looking forward to the release :)
     
  34. onopko123

    onopko123

    Joined:
    Jun 9, 2020
    Posts:
    5
    Hi, I read through the thread. I tried so many things but I can't manage to create a Tile Palette with gameobjects/prefabs.
    1. I already have a grid, a tilemap and a palette for the ground. I created an extra tilemap called 'Enemies' and added 3 prefabs:
    Hierarchy.PNG
    Tilemap in the inspector:
    Tilemap.PNG
    2. I tried to move the prefabs into the palette or a new palette, but nothing happens. I get the '+' sign as I drag them over, giving me hope every time I try, but the palette stays empty.

    The only way to paint with the prefabs is by:
    1. Creating a new prefab brush for each one. (or a random prefab brush)
    2. By selecting the 'GameObject Brush' from the Tile Palette window/tab and pick objects included in the 'Active Tilemap' with the pick tool (I) from the scene.
    3. Select the 'GameObject Brush' and set a size and set elements. Though I can only paint with the first one, did not get how to use the other objects set.
    TilePalette.PNG

    Is it actually possible to have a palette with prefab objects in it? From which I can pick and paint with. I can pick objects from the scene with the 'GameObject Brush' it would be nice to have the option to set a palette and do the same from there.

    Thank you! Sorry if I picked the wrong thread to post this question.
     
    Last edited: Nov 11, 2020
  35. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Yes, you can, from Unity 2020.1 onwards.

    To set Prefab Objects in the Tile Palette, you will need to:
    • Make the Tile Palette editable by toggling the Edit button
    • Select GameObject Brush in the dropdown
    • In the Brush Inspector for the GameObject Brush, set up the Brush with a Prefab. Alternatively, you can pick the Prefab from the SceneView using the GameObject brush
    • Paint the Prefab onto the Tile Palette
    • Save the Tile Palette by toggling the Edit button
    You will be able to pick and paint the Prefabs using the GameObject Brush from the Tile Palette.
     
    onopko123 likes this.
  36. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Could you share which version of the Tilemap Extras you are using? This should be fixed in the 1.6.2-preview.
     
    onopko123 likes this.
  37. onopko123

    onopko123

    Joined:
    Jun 9, 2020
    Posts:
    5
    Hi,

    Sorry for the late response. Did not expect someone to reply so fast, I am impressed.
    So I did update from 2019.4.13f to 2020.1.13f not long ago for another reason. And now I tried what you explained above and it worked! Now I can create a palette with the prefabs I wish!

    Thank you so much!
     
  38. onopko123

    onopko123

    Joined:
    Jun 9, 2020
    Posts:
    5
    Now with 2020.1.13f I guess I updated to 1.6.2, since I am now using 'https://github.com/Unity-Technologies/2d-extras.git#master' in my manifest.json file.