Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Latest commit

 

History

History
73 lines (49 loc) · 3.19 KB

File metadata and controls

73 lines (49 loc) · 3.19 KB

File Structure

**Separation of Concerns**: Divide code into logical blocks, separating UI, management, and controller functionalities into different namespaces and files.

Use of Namespaces: Group related classes within appropriate namespaces to organize code and prevent naming conflicts.

Comments and Documentation

**Method Summaries**: Provide XML documentation comments for public methods and properties, describing their purpose, parameters, and return values.

Inline Comments: Use inline comments to explain complex logic or important decisions within methods.

Header Attributes: Use [Header("...")] attributes to group and label serialized fields in the Unity Editor.

Tooltip Attributes: Utilize [Tooltip] attributes for public fields exposed in the Unity Editor to explain their purpose or usage.

Error Handling

**Null Checks**: Perform null checks on objects before accessing their members.

Performance

**Object Pooling**: Use object pooling for frequently created and destroyed GameObjects, such as projectiles or enemies.

Efficient Updates: Minimize expensive operations in the Update and FixedUpdate methods. Where possible, use event-driven approaches to reduce the need for constant checks each frame.

Unity Best Practices

**Coroutines**: Use coroutines for asynchronous operations and time-based events.

Invoke Methods: Use the Invoke and InvokeRepeating methods for simple time-based events.

Avoid Find Methods: Minimize the use of the GameObject.Find method, as they can be expensive and inefficient.

Coding Practices

**Early Returns**: Use early returns to reduce nesting and improve readability.

Consistent Naming: Use consistent naming conventions for variables, methods, and classes to improve code readability and maintainability.

Readonly Modifier: Apply the readonly modifier to fields that should not change after initialization.

Constants: Use constants for values that should not change, such as magic numbers or strings.

Consistent Formatting: Use consistent formatting and indentation to improve code readability and maintainability.

Method Length: Aim to keep methods short and focused on a single responsibility. Refactor long methods into smaller, more manageable pieces.

Region Directives: Use region directives to group related methods or fields within a class.

Modular Design: Aim to create modular, reusable components and systems that can be easily extended or modified.

Abstraction: Use interfaces and abstract classes to define common behavior and allow for polymorphism.

Inheritance: Use inheritance judiciously, favoring composition and interfaces over deep inheritance hierarchies.

Hierarchy

``` ├── [Managers] ├── Main Camera ├── Lights ├── Entities/ │ ├── Player │ ├── Enemy0 │ ├── Enemy1 │ └── ... ├── World/ │ ├── Terrain/ │ │ └── Grid │ ├── Props │ └── ... └── Interface/ ├── HUD ├── Pause Menu ├── Victory └── Settings Menu ```