Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Hexagonal Rule Tile doesn't work in 2022.2 Beta

Discussion in '2022.2 Beta' started by msosnin, Oct 17, 2022.

  1. msosnin

    msosnin

    Joined:
    Aug 4, 2019
    Posts:
    8
    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: https://drive.google.com/file/d/1t_HcMMpHUBj1W8odybuME78Bh0aDdJ_p/view?usp=sharing

    I am using Mac silicon 2022.2.0b10 version.
     
  2. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    297
    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
     
    Last edited: Oct 23, 2022
  3. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    297
    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.
     
    Last edited: Oct 25, 2022
  4. msosnin

    msosnin

    Joined:
    Aug 4, 2019
    Posts:
    8
    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)
     

    Attached Files:

  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    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<T> from RuleTile.cs to a new file, eg. RuleTileTemplate.cs.

    Code (CSharp):
    1. /// <summary>
    2.     /// Generic visual tile for creating different tilesets like terrain, pipeline, random or animated tiles.
    3.     /// This is templated to accept a Neighbor Rule Class for Custom Rules.
    4.     /// </summary>
    5.     /// <typeparam name="T">Neighbor Rule Class for Custom Rules</typeparam>
    6.     public class RuleTile<T> : RuleTile
    7.     {
    8.         /// <summary>
    9.         /// Returns the Neighbor Rule Class type for this Rule Tile.
    10.         /// </summary>
    11.         public sealed override Type m_NeighborType => typeof(T);
    12.     }
     
    mandisaw and Kmsxkuse like this.
  6. msosnin

    msosnin

    Joined:
    Aug 4, 2019
    Posts:
    8
    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!
     
  7. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    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.
     
    Kmsxkuse likes this.
  8. msosnin

    msosnin

    Joined:
    Aug 4, 2019
    Posts:
    8
    Still have a problem.

    Attached is a sample project: https://drive.google.com/file/d/12ivMyJoG0eSXrHP-R8e07gQUUqdwqGWm/view?usp=share_link

    Steps:
    1) Create empty 3D project "TileTest3"; in package manager: "add package from url:"https://github.com/Unity-Technologies/2d-extras.git#package_2022.1_ruletilefix
    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).
     
    Last edited: Nov 5, 2022
  9. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Sorry about this, we will check it out!
     
  10. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    @msosnin I updated the branch with a fix for the HexagonalRuleTile. I forgot to update the HexagonalRuleTile<T> 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!
     
  11. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Just an update, this will be fixed in 2022.2.0b16!
     
    mandisaw and TreyK-47 like this.
  12. msosnin

    msosnin

    Joined:
    Aug 4, 2019
    Posts:
    8
    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
     
  13. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    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!
     
  14. msosnin

    msosnin

    Joined:
    Aug 4, 2019
    Posts:
    8
    Hello! In 2022.2.0b16 it works properly. Thanks for fixing.