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

2,281 views

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 rainer@rarebyte.com www.shadesofplay.at
  2. 2. Static Code Analysis • Gendarme • Unity rules https://github.com/fderudder/unity-gendarme
  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 • https://unity3d.com/learn/tutorials/modules/ 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: http://www.somasim.com/blog/2015/04/csharp -memory-and-performance-tips-for-unity/ • for-each vs. for etc. • GC
  11. 11. Questions? Rainer Angermann @rangermann rainer@rarebyte.com

×