Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

How best to get tile data in Preview 4?

Discussion in '2D Experimental Preview' started by Fraxinus, Jul 7, 2017.

  1. Fraxinus

    Fraxinus

    Joined:
    Jan 4, 2014
    Posts:
    1
    I was wondering the best way to get tile data in Preview 4?

    The code below worked in the prior version, but now it's throwing an error. Because I couldn't easily solve the error, I was wondering if I should be going a different route to finding custom properties on a tile (that I assigned via script).

    TileData td1 = new TileData();
    TileBase tb1;

    if (TileLocationIsInMapBoundary(tileLoc))
    {
    tb1 = GameManager.GMinstance.WorldTileMapLayer0.GetTile(tileLoc);
    tb1.GetTileData(tileLoc, GameManager.GMinstance.WorldTileMapLayer0.GetComponent<ITilemap>(), ref td1);
    etc...

    ArgumentException: GetComponent requires that the requested component 'ITilemap' derives from MonoBehaviour or Component or is an interface.
    UnityEngine.Component.GetComponent[ITilemap] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ComponentBindings.gen.cs:48)
    Completed.TileTransitions.CalculateTileTransMask (Vector3Int tileLoc) (at Assets/Scripts/Terrain/TileTransitions.cs:261)
    Completed.TileTransitions.AddTransitionGameObject () (at Assets/Scripts/Terrain/TileTransitions.cs:92)
    Completed.TileTransitions.Start () (at Assets/Scripts/Terrain/TileTransitions.cs:35)​