Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    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)​