Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Code Analysis
by
Rainer Angermann
@rangermann
rainer@rarebyte.com
www.shadesofplay.at
Static Code Analysis
• Gendarme
• Unity rules
https://github.com/fderudder/unity-gendarme
GetComponent() Calls
• Cache your components!
• Avoid GetComponent() calls in Update()
• Avoid this:
Empty MonoBehaviour Methods
• Avoid this:
• Overhead!
Profiler
Sounds
• Avoid this:
• Suggestion:
Pooling
• Expensive Instantiate() calls
• Use a pool for game objects that need to be
instantiated/killed frequently
• htt...
Profiler: Comparison
General Advice
• Code style/readability (format your code!)
• Use English for all names etc.
• Do not be afraid of refacto...
Advanced Optimization
C# Memory and performance tips for Unity:
http://www.somasim.com/blog/2015/04/csharp
-memory-and-per...
Questions?
Rainer Angermann
@rangermann
rainer@rarebyte.com
Shades of Play: Code Analysis/Unity Performance Tips
Nächste SlideShare
Wird geladen in …5
×

Shades of Play: Code Analysis/Unity Performance Tips

1.975 Aufrufe

Veröffentlicht am

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

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

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

×