Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What's Optimal for a Sprite Renderer: Child GameObject or Component?

Discussion in 'Editor & General Support' started by mstarr, Aug 28, 2019.

  1. mstarr

    mstarr

    Joined:
    Jun 20, 2018
    Posts:
    135
    I am wondering, from a design perspective as well as a code optimization, what is optimal if I want to add a SpriteRenderer to a GameObject: to have it be a child in the GameObject heirarchy, or to add it as a Component to the GameObject?

    The effect seems to be the same, but certainly one is faster than the other, or more convenient in the long run?

    What if the GameObject is a Prefab and we'll be using it thousands of times in a game? Then one being marginally faster than the other may start to add up.

    Anyone have any opinions?

    Muchos Gracias,
    Michael
     
  2. nick-morhun

    nick-morhun

    Joined:
    May 12, 2015
    Posts:
    51
    Another GameObject always uses more resources than a Component
     
  3. mstarr

    mstarr

    Joined:
    Jun 20, 2018
    Posts:
    135
    Thanks, that clarifies things.