0

I'm using Unity 4.6 to develop a 2D game. I want to know if having a lot of GameObjects in the scene (out of the camera's sight) has a considerable influence on performance. For example, is it efficient to make an scrollable list of names (like 1000 of them)? (each one is a GameObject and has a text, a button etc.) I mask them in a specified area (for example 10 of them are visible at the same time).

Thanks in advance!

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Sean Ed-Man
  • 378
  • 4
  • 8

1 Answers1

1

Depends on whether or not the objects have visible components. If they do, the engine will draw them even if they are 'off-camera'. A game object by itself has a pretty light load - a tile based game could have thousands in memory. You'll want to toggle the visibility of sprites if you plan on drawing a large number to the scene off-camera. This is where a SpriteManager comes in. It'll check to see if the sprite is in the camera's rectangle and disabled sprites that aren't. There is a semi-offical exmaple here that is good if a little complicated:

http://wiki.unity3d.com/index.php?title=SpriteManager

ChargerIIC
  • 1,620
  • 1
  • 33
  • 47
  • Does the built in 2D features of the Unity (like SpriteRenderer) manage this? Or I have to disable the SpriteRenderer once it goes off-camera? How about the UI elements in new GUI system recently added in Unity 4.6? – Sean Ed-Man Dec 31 '14 at 01:03
  • Currently the engine will continue to draw sprites off camera. UI elements are normally defined within the camera's view so that hasn't brought a change. I don't know if Unity is planning on changing this behavrior - while many 3d games benefit from drawing off camera objects, 2d tile based games dont as much. Maybe in unity 5.0+ – ChargerIIC Dec 31 '14 at 14:59