Code Conventions

Structure

 * Interfaces vs. Tags
 * Tags define what an object is
 * Interfaces define behaviour


 * (Stateless) classes should be static
 * Their variables should be editable through the editor using editor scripts.


 * Use Events whenever multiple sources need to subscribe to change


 * Store constants (like tags) in a separate class rather than hardcoding strings


 * Use empty GameObject called "Managers" as a parent for empty GameObjects containing manager scripts
 * Managers are scripts that do not depend on being attached to specific GameObjects

Best Practices

 * Stray from using expensive operations like GetComponent, Find, Raycast, etc.
 * Try to use them as little as possible


 * transform, gameObject and the likes are hidden GetComponent calls and hence should be called as little as possible


 * A good practice is caching them in Start


 * Debug messages cost a lot and should (obviously) only be used for debugging. Do not leave it in the code.


 * When comparing tags use CompareTag instead of GameObject.tag == tag