Unity Optimization Tips !

Hi Everyone,
I am stuck on thinking which thing causes a lag in unity and how to optimize it…
i need help on the following topics !

  1. Does The Length Of The Script Makes A Game Slower?
  2. Which is better, a table made inside unity from 5 cubes or a table imported from a 3d modelling software carved out from a single cube?
  3. Does the function Update reduces the optimization of the game? In other words does an empty function update in every script reduces the speed of game, even by 0.001%?
  4. can co-routines be used as an alternative to Function Update?
  5. Which is better Co-routine, update or fixed update?
  6. I have a script in my game which generates about 100 low-poly trees, 100 low-ply rocks and 1000 traps(considering each trap having 4 blocks), and all these have a script attached to them, so in other words about 1200 scripts are working, is this ok?
  7. Does making an object child reduces lag?
  8. Which type of texture to use, low quality or high quality?
  9. And finally, which sounds are to be compressed more, large sounds(like background musics, etc.) or short sounds(like spells, button click, etc,)?
  10. How can i view the size occupied by each of the item in total? like texture occupies 100MB, sound occupies 80 mb, etc.

Thanks

EDIT :
one maint thing i forgot to ask,
which scripting language is optimizing wise best? Java, C++, or boo?

  1. Script length doesn’t matter. Maybe a teeny, tiny bit, but that’s really splitting hairs. That said, script length does affect compile time. At runtime, it’s all about what each line does.
  2. Sounds like you’re not yet familiar with draw calls, batching, and other optimization-specific aspects of the render pipeline. Bottom line, fewer objects is better, even if your group of objects has the same number of verts/tris as your single object. See the docs for more on this.
  3. Having an empty Update(){} does affect performance. Probably by 0.001%, but yes. Empty functions are executed, which takes a measurable amount of time.
  4. Co-Routines are a very powerful feature. A common usage for them is executing code every N seconds instead of every frame, which can offer huge optimizations depending on what’s being done.
  5. No such thing as “better” - Update is for things that must happen every frame. FixedUpdate is for things which interact with physics (it has other uses too). Co-Routines are not simply alternatives to Update/FixedUpdate/LateUpdate, but are tools you can use to build smarter, cleaner, and more efficient algorithms.
  6. Having this many objects or scripts isn’t “bad”. It also doesn’t sound super good. When working on projects with tons of objects and scripts, it’s important to consider exactly how much work is being done, and whether you can reduce that workload. (Protip: The answer is almost always “yes” for a long, long time… Until it’s not.)
  7. Parent/Child relationships have almost no bearing on performance.
  8. Import the highest quality textures you have. Their import settings and the project quality settings help determine whether high or low res versions are used.
  9. All I really know about this is compression is good, until it’s not. Meaning, compress as heavily as you choose while ensuring the sound quality is acceptable.
  10. If you have Unity Pro, you have access to the Profiler, which gives detailed info about memory usage, performance, and many other things.

Just because I never turn down an opportunity to steer new programmers away from unityscript and boo, I’ll strongly recommend C#. Very, very strongly. You’ll thank me some day if you do. Or say “Man, that guy was right…” someday if you don’t.

Good Luck moving forward and learning more about Unity,