Hexagonal Rule Tile doesn't work in 2022.2 Beta

Steps to reproduce:

  1. create fresh project
  2. in package manager add components: 2D Tilemap Editor, 2D Tilemap Extras
  3. in project panel, right click - Create - 2D - Tiles - Hexagonal Rule Tile
  4. Click on just created tile, you will see parameters of the tile displayed in the inspector panel (correct)
  5. Save and exit the project.
  6. Open the project again
  7. Click on the tile object. You will see in the inspector “Associated script can not be loaded”

It is not possible to use the tiles.

Same problem occurs when upgrading existing working projects (with tilemaps) to the 2022.2. I did not find the work-around yet.

Other types of tiles seem not work as well.

How it can be fixed?

Sample project: TestTile.zip - Google Drive

I am using Mac silicon 2022.2.0b10 version.

Yep. Same problem here. All the rule tiles except for Rule Override Tile scripts seem to be broken.

Just opened a bug report: CASE IN-20799

TL;DR: If RuleTiles arent working, re-import the 2D Tilemap Extras package folder. And keep doing it until it fixes the problem.

Alright, the problem appears to be some AssetDatabase cache issue according to people who had similar problems over the years.

I’m experimenting with a manual workaround right now.

Workaround: locate your 2d tilemap extras package in the “project” and reimport (not reimport all, just regular reimport" the entire folder inside the editor.

If the editor tile editing tool dies again, reimport the package and it’ll fix it.

If you mistakenly selected the “RuleTile.cs” script in the “no script found”, you will need to manually re-import the asset.

Simply create a new RuleTile asset and, in a text editor like notepad, copy paste the “m_TilingRules:” section all the way to the bottom from the broken asset to the newly created asset. Everything else doesnt matter.

It will most likely break again and just re-import the 2D Tilemap Extras package folder again.

You will get this error “SerializedObjectNotCreatableException: Object at index 0 is null” constantly but, like all good unity programmers, ignore it. The RuleTile will work with the tile palette painter and in-game.

Attempting to manually fix the error by replacing the null file marker in the asset will break the editor like selecting the RuleTile.cs file above, requiring the manual reimport steps described above so dont do that.

Hypothetically, an easier way to fix broken existing assets is to go into the .assets file using a text editor and locate and replace the following lines with the below:

m_Script: {fileID: 0}

m_EditorClassIdentifier: Unity.2D.Tilemap.Extras:UnityEngine:RuleTile

And reimport the 2D Tilemap Extras package.

Reloading editor will also require reimporting the 2D Tilemap Extras package after startup in order for the tile assets to register as RuleTiles. The tilemap will still appear normally with tiles painted on it but editing the tilemap with a tile palette or runtime tile editing will require at least one reimport of the 2D Tilemap Extra folder.

Hello! Thanks, the reimporting helps to enable editing the tile in the editor, however, I still can not use it in the game.

I need to assign the tile reference to the game script field (of TileBase type) in inspector, so I drag-n-drop the tile into the inspector, but get the error message “Can’t assign script” (attached).

Tried to reimport the “2D Tilemap Extras” package once again, just prior to drag-n-drop operation, but with the same result. Please see the screenshot (the blue field in the inspector is one that is causing the error when dragging the “TunnelTileNew” to it)

Hi, sorry about this issue! This will be fixed in a future version of the 2022.2 editor.

As a temporary local fix, you could clone a local copy of the package in your project and move the following lines of the class RuleTile from RuleTile.cs to a new file, eg. RuleTileTemplate.cs.

/// <summary>
    /// Generic visual tile for creating different tilesets like terrain, pipeline, random or animated tiles.
    /// This is templated to accept a Neighbor Rule Class for Custom Rules.
    /// </summary>
    /// <typeparam name="T">Neighbor Rule Class for Custom Rules</typeparam>
    public class RuleTile<T> : RuleTile
    {
        /// <summary>
        /// Returns the Neighbor Rule Class type for this Rule Tile.
        /// </summary>
        public sealed override Type m_NeighborType => typeof(T);
    }
2 Likes

I can not make it to work.

I have tried two approaches:

  1. I clone whole packages “2D TileMap Editor” and “2D TileMap Extras” to my assets, and then remove these packages from PackageManager.
    In this case I have compile errors such as “GridBrushEditorBase definition not found”, regardless of manipulations with
    RuleTile.cs.

  2. I keep the packages, but modify file RuleTile.cs by removing from it the code snippet you mentioned and create only one extra file with this code.
    In this case I have same mistake as before when trying to drag my tile to the inspector field.

Probably, I misunderstood what exactly is to be done for the fix. Could you please clarify. Thanks a lot!

I added a temporary branch to the 2d extras repository to workaround this bug. You can access it through the following methods:

Let me know if that works out!

Ultimately, this will be fixed with a new version of the Unity Editor rather than through a package update. The only timeline I can give right now is that it will be fixed in the release of the 2022.2 editor.

1 Like

Still have a problem.

Attached is a sample project: TileTest3.zip - Google Drive

Steps:

  1. Create empty 3D project “TileTest3”; in package manager: "add package from url:"GitHub - Unity-Technologies/2d-extras: Fun 2D Stuff that we'd like to share!
  2. Add empty GameObject to SampleScene, add component “New script” to the GameObject (GameObjectScript)
  3. In GameObjectScript.cs add lines:
    using UnityEngine.Tilemaps;
    [SerializeField] private TileBase _testTile;
  4. In Unity in Project panel under Assets folder right-click, Create->2D->Tiles->Hexagonal Rule Tile
  5. In Hierarchy panel select GameObject in MainScene; drag “New Hexagonal Rule Tile” to inspector field “Test Tile” (it works OK)
  6. Save the scene

What is wrong (in Editor):
A) if click to small circle near the “Test Tile” field in Inspector - it shows empty list for “Select Tile Base” menu
B) If close and reopen Unity, the field “Test Tile” for the GameObject shows empty “None (Tile Base)” again.

Most important: if I reimport the Extras library, reactivate the tile, it starts working in editor player (so the fix is working up to this point) But: in compiled bundle the tiles do not work. Most probably, during compilation the references do not compile properly, although I want to mention that after the compilation the project is still working fine in the editor player (until Unity restart).

Sorry about this, we will check it out!

@msosnin I updated the branch with a fix for the HexagonalRuleTile. I forgot to update the HexagonalRuleTile class to fix this issue.

You may have to delete the Packages/packages-lock.json file in your project to get the updated version.

Let me know if that works for you!

Just an update, this will be fixed in 2022.2.0b16!

2 Likes

Hello!

Applied the fix. After I reimport the 2DTilemap Editor and 2D TileMap Extras packages, it works in play mode.
However, after restarting Unity it stops working, and I need to reimport the packages again.
This seems wrong to me. May I have missed something?
Is it how it supposed to be and I can proceed to bundle building?

Thanks,
Mikhail

Does this still happen with 2022.2.0b16? This should be available for download now.

If it does still happen with 2022.2.0b16, could you file a bug report with the Unity Bug Reporter with your project and your steps for asset bundling? We may have to test it out with your steps to reproduce this. Thanks!

Hello! In 2022.2.0b16 it works properly. Thanks for fixing.