Search Unity

  1. Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  3. Dismiss Notice

Instantiate prefab Performence

Discussion in 'Prefabs' started by Sherwinnie, Apr 29, 2020.

  1. Sherwinnie

    Sherwinnie

    Joined:
    Jan 24, 2020
    Posts:
    18
    Currently I am making a 3D rhythm game, and I am noticing some performance problems that I can not seem to optimize. The game runs pretty smoothly on my Mac Pro, but when I switch to Mac Mini (2018), the frame rate drops really really bad. It makes me wonder on how I should generate my notes. Currently I am instantiating prefeb to actual note object as the song plays and destroying them when they are hit or missed. However, since I know how many notes I am about to generate because I wrote each music chart myself, I am wondering if I should instantiate all the note objects before the start of the song, hide them to somewhere that the player can't see, and only show them when needed. Will this improve the performance?

    ps. the note prefab only has Cube (Mesh Filter) and Mesh renderer as its components, so they don't have the collider and rigidbody component.
     
  2. Soraphis

    Soraphis

    Joined:
    Oct 25, 2013
    Posts:
    8
    instantiating at the start and enable when needed -> huge amount of objects, larger startup time, but you get rid of the lag.

    BUT: look into pooling systems, reuse elements and don't delete them.

    or go with ECS, since your notes are basically really easy objects, without much logic. all of them move at the same speed (speed of the song) and are rendering a simple mesh.

    this is basically perfect for ECS
     
unityunity