shades of play: code analysis/unity performance tips

12
Code Analysis by Rainer Angermann @rangermann [email protected] www.shadesofplay.at

Upload: rainer-angermann

Post on 13-Apr-2017

1.549 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Shades of Play: Code Analysis/Unity Performance Tips

Code Analysis by

Rainer Angermann @rangermann

[email protected]

www.shadesofplay.at

Page 2: Shades of Play: Code Analysis/Unity Performance Tips
Page 3: Shades of Play: Code Analysis/Unity Performance Tips

Static Code Analysis

• Gendarme

• Unity rules

https://github.com/fderudder/unity-gendarme

Page 4: Shades of Play: Code Analysis/Unity Performance Tips

GetComponent() Calls

• Cache your components!

• Avoid GetComponent() calls in Update()

• Avoid this:

Page 5: Shades of Play: Code Analysis/Unity Performance Tips

Empty MonoBehaviour Methods

• Avoid this:

• Overhead!

Page 6: Shades of Play: Code Analysis/Unity Performance Tips

Profiler

Page 7: Shades of Play: Code Analysis/Unity Performance Tips

Sounds

• Avoid this:

• Suggestion:

Page 9: Shades of Play: Code Analysis/Unity Performance Tips

Profiler: Comparison

Page 10: Shades of Play: Code Analysis/Unity Performance Tips

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)

Page 12: Shades of Play: Code Analysis/Unity Performance Tips

Questions?

Rainer Angermann @rangermann

[email protected]