Search Unity

SpriteMeshGenerator.TraceShape lag spike on activating a gameobject

Discussion in '2D' started by drHogan, Dec 6, 2018.

  1. drHogan

    drHogan

    Joined:
    Sep 26, 2012
    Posts:
    201
    Hello guys,

    I have a 2D game setup made so that when the level loads, it loads several elements from AssetBundles, instantiates them and then deactivates them. In the specific they are building placeholders, so when you do click "build" in game, they do activate and stick to the mouse until you position them and you give the building order.

    These placeholders are nothing too fancy, basically 3 sprites parented (the building visuals, a base that shows the occupied space on grid and the preview area of the building. Each of the 3 is direct child object of a gameobject that holds the script of the placeholder (that basically when active follows the mouse, changes color based on the grid values underneath, etc).



    The building belongs to a spritesheet of 2048x1024 (2.7 Mb) with the other states of the same building.

    Now, the moment the placeholder activates, I get a HUGE lag spike. I have other 3 similar placeholders and have the same issue, also the one that is not loading the textures from AssetBundle but it's already in scene in the editor.

    The spike is huge, we are talking about 38 to 50 ms for a game that is in average running at 60fps with no problems at all and I can only trace it back to EventSystem.Update() but with no further details. Any idea what this issue exactly means and what could be done to solve it? I am running Unity 2017.3.1f1

    Cheers,
    H
     
    ImpossibleRobert likes this.
  2. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    527
    Did you ever find a solution to this? I get the same
     
  3. drHogan

    drHogan

    Joined:
    Sep 26, 2012
    Posts:
    201
    I must confess, i don't remember :D I think I did, but I can't really say what was the cause, sorry! If anything, i had similar problems of late, and the issue was mostly caused by colliders, specially polygon ones. In that case i also had several colliders, but i can't vouch it's the same cause unfortunately.