Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Very slow object duplication / deletion

Discussion in '2D' started by CoolJosh3k, Mar 25, 2020.

  1. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    77
    In an almost empty test scene I layed out some tile using the tilemap feature.
    • 64x512, 1x1 tiles.
    • Each tile has only a sprite renderer and the sprites are all 16x16 pixel textures.
    • I created every tile using a Prefab Brush (Tilemap Extras).

    Trying to duplicate these takes many, many minutes.
    Trying to delete them all takes a very long time too.

    Is there anything I can do to make working with many tiles managable? This was only a small sample!

    ---
    Unity: 2019.3.4f1
    2D Tilemap Editor: 1.0.0
    Tilemap Extras: 1.4.0
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    155
    PrefabBrush creates GameObjects. These are going to be significantly slower than normal TileBase-derived tiles, which are ultimately lightweight ScriptableObjects and, in typical usage, only have one instance per tile kind no matter how many you draw. Given the dimensions, you have over 32,000 GameObjects. Would it be possible to not use the prefab brush? A more intended usage is to draw as much as you can without prefabs, and fill in anything that needs the extended functionality of a full GameObject with the prefab brush.

    If you drag your sprite into the Tile Palette it'll automatically create a Tile with that sprite. If you use that instead, that should solve the problem significantly.
     
    eses likes this.
  3. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    77
    Well I tried as suggested and used the most basic of tilemap functionality.

    It was the same. Many, many minutes of nothing happening while I wait for Unity to do my next request. All I did was create an area filled with tiles (all the same 16x16 pixel texture).

    Once I had finally managed to get to hitting that play scene button half an hour later, it took so long to start. Once running there was absolutly no issues running my game.

    I feel like just using gameobjects for everything was better, based on how long I had to wait for something to respond in the editor.
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    155
    This definitely sounds like abnormal and not-intended behavior. It should be seconds or less. You're painting a scene from a Tile Palette within the Editor? Or are you procedurally placing the tiles via script?

    Check out the Robodash demo, check out the Unity 2D Techdemos. If you load their test scenes, are they slow for you too? If you create a tile with your art and paint over an existing scene in one of those projects, does the slowness resume?
     
  5. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    77
    I tested removing the prefab connection with "unpack prefab" and that solved the issue.

    Real shame I cannot have attached script that does stuff based of the tile location.
     
unityunity