Search Unity

Unity 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

    6 vote(s)
    50.0%
  2. No

    6 vote(s)
    50.0%
  1. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    325
    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:
    21
    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:
    325
    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:
    21
    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:
    325
    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:
    21
    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:
    325
    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:
    147
    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:
    325
    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:
    325
    Yes, this will be the case.
     
  12. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    147
    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:
    325
    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:
    6
    How can I use code to generate a Palette and import Tile to Palette?
     
  16. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    325
    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:
    6
    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:
    144
    Will tileMap could be editored in run-time in futher Unity versions?:D
     
  19. TextusGames

    TextusGames

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

    Bagazi

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

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    147
    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:
    144
    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:
    147
    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:
    325
    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:
    21
    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:
    325
    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.