Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Shades of Play: Code Analysis/Unity Performance Tips


Published on

Some very useful Unity performance optimizations tips based on a quick code analysis of the Shades of Play project.

Published in: Technology
  • Be the first to comment

Shades of Play: Code Analysis/Unity Performance Tips

  1. 1. Code Analysis by Rainer Angermann @rangermann
  2. 2. Static Code Analysis • Gendarme • Unity rules
  3. 3. GetComponent() Calls • Cache your components! • Avoid GetComponent() calls in Update() • Avoid this:
  4. 4. Empty MonoBehaviour Methods • Avoid this: • Overhead!
  5. 5. Profiler
  6. 6. Sounds • Avoid this: • Suggestion:
  7. 7. Pooling • Expensive Instantiate() calls • Use a pool for game objects that need to be instantiated/killed frequently • beginner/live-training-archive/object-pooling
  8. 8. Profiler: Comparison
  9. 9. General Advice • Code style/readability (format your code!) • Use English for all names etc. • Do not be afraid of refactoring/renaming • Use a portrait resolution if your game is portrait • MonoBehaviour/inspector: Use private members with [SerializeField] • Unity Console (errors/warnings)
  10. 10. Advanced Optimization C# Memory and performance tips for Unity: -memory-and-performance-tips-for-unity/ • for-each vs. for etc. • GC
  11. 11. Questions? Rainer Angermann @rangermann