Search Unity

Question World Canvas Prefab Instantiation Delta Time

Discussion in 'Prefabs' started by NandusMasta, Aug 2, 2020.

  1. NandusMasta

    NandusMasta

    Joined:
    Apr 9, 2011
    Posts:
    63
    Hey everyone. I am having a problem optimizing the code of my game, in order to be able to generate over 3000 thousand canvas objects in world space mode. My code takes less than 40 seconds to set up the scene, however when I want to instantiate these gameobjects, the time jumps to over 160 seconds. That's totally unacceptable.

    I have over 20000 objects in the scene without problems, however these canvases are eating up my start up time. I am considering creating a pool and just reuse them, as the player will never see all of the them at the same time. However this might create a stuttering of lag for the player as he scrolls through the map(the object needs to be reparented and the view model updated). I also considered creating a cache of them in a previous scene, but that just moves the problem to the game initialization, before it actually starts; without really resolving it.

    It didn't made any difference from what I can gather, but I made sure the objects are set the UI layer and marked as static. In game performance is pretty good with everything already set up, the problem is in the initialization time.

    In any case, any comments or suggestions on this would be most welcomed. Thanks in advance!