Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Do disabled components get built?

Discussion in 'Editor & General Support' started by KarlKarl2000, Feb 13, 2023.

  1. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    600
    Hello all

    I've been making my game with probuilder, in order to see them in the editor I've used this mesh renderer.

    If the mesh renderer is disabled, will Unity build that into the final game?

    Should I remove this mesh renderer from the prefab? It'll basically affect every level in the game.

    Thanks for the help
    upload_2023-2-13_11-3-15.png
     
  2. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    717
    I would expect so, yes -- Unity would have a very hard time proving that you never try to turn the component back on at runtime!
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,450
    Yeah, but so what? The performance impact will be infinitesimal. You should probably just leave it on in case you need to adjust the mesh later.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    37,265
    Nah, don't bother. If you want to double-triple make sure those particular Renderers get turned off at runtime, just make a little script that GetComponent<MeshRenderer>()s for them and sets them not enabled and put that script on each of these objects. Or Destroy()s the MeshRenderer in Start(). Either way it is unlikely to amount to a hill of beans memory or performance wise.
     
  5. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    600
    Ok got it. Thanks for the confirmation everyone.

    I'll leave the mesh renderers disabled just in case I need to make adjustments to the prefab later down the road.