What's new

GameDesign Directory Structure for Controllers and Managers in Unity

Under

Administrator
Unity King Developer

Directory Structure for Controllers and Managers in Unity​

Importance of Directory Organization​

A well-organized directory structure is crucial for efficient and sustainable software development, especially in complex game projects. Keeping controller and manager scripts in dedicated directories not only makes it easier to locate files but also aids in project maintenance and scalability.

Recommended Structure​

To further improve the organization, we’ll place Controllers and Managers inside the Scripts folder to maintain a clean hierarchy. This structure supports scaling and makes it easier to manage various aspects of the game’s functionality.

Assets/Scripts/Controllers​

This directory should contain all scripts that handle player input and direct manipulation of game objects. A clear organization within this folder allows developers and new team members to quickly find scripts responsible for controlling the actions of characters, vehicles, or other interactive elements.

Code:
Assets/Scripts/Controllers
    ├── CharacterController.cs
    ├── VehicleController.cs
    ├── CameraController.cs
    └── InputController.cs       # For handling input devices like mobile or VR controllers

Assets/Scripts/Managers​

Scripts that manage the global game state, event logic, inventory, and other systems should be stored here. This centralizes high-level game logic, making it easier to manage critical components like level loading, player data management, and more.

Code:
Assets/Scripts/Managers
    ├── GameManager.cs
    ├── InventoryManager.cs
    ├── AudioManager.cs
    ├── UIManager.cs             # Manages UI states and transitions
    ├── LevelManager.cs         # Handles level loading and progression
    └── SaveLoadManager.cs      # Manages saving/loading player data

Expanded Folder Structure for a More Organized Project​

Code:
Assets/
    ├── Scripts/
    │   ├── Controllers/
    │   │   ├── CharacterController.cs
    │   │   ├── VehicleController.cs
    │   │   ├── CameraController.cs
    │   │   └── InputController.cs
    │   ├── Managers/
    │   │   ├── GameManager.cs
    │   │   ├── InventoryManager.cs
    │   │   ├── AudioManager.cs
    │   │   ├── UIManager.cs
    │   │   ├── LevelManager.cs
    │   │   └── SaveLoadManager.cs
    │   ├── Utilities/
    │   │   ├── Timer.cs
    │   │   └── ObjectPool.cs
    │   ├── Networking/
    │   │   ├── NetworkManager.cs
    │   │   └── NetworkPlayer.cs
    │   └── Extensions/
    │       ├── RigidbodyExtensions.cs
    │       └── Vector3Extensions.cs
    ├── UI/
    │   ├── MainMenu/
    │   │   ├── MainMenuController.cs
    │   │   └── StartButton.cs
    │   ├── InGameUI/
    │   │   ├── HUDController.cs
    │   │   └── PauseMenu.cs
    │   └── UIElements/
    │       └── Buttons/
    │       └── Sliders/
    ├── Animations/
    │   ├── PlayerAnimations/
    │   └── EnemyAnimations/
    ├── Audio/
    │   ├── Music/
    │   ├── SoundEffects/
    │   └── VoiceOver/
    ├── Prefabs/
    ├── Materials/
    ├── Textures/
    └── Scenes/
        ├── MainMenu.unity
        ├── Level1.unity
        └── Level2.unity

Benefits​

Modularity: Organizing scripts into specific directories promotes a modular architecture, making it easier to reuse, test, and modify individual components without affecting other parts of the game.
Collaboration: In teams, intuitive file locations reduce the time spent searching for specific resources and improve collaboration among developers.
Maintenance: A clear structure facilitates maintenance, especially for long-term projects or those undergoing many development iterations.

Implementation and Best Practices​

  • Consistency: Keep naming conventions and directory structures consistent throughout the project to avoid confusion.
  • Documentation: Document the directory structure and naming conventions at the start of the project to ensure that everyone on the team understands and follows established practices.
  • Review and Refactor: Periodically review the directory structure to ensure it remains suitable as the project evolves.

Conclusion​

Efficient directory organization for controllers and managers is a fundamental practice that directly impacts the effectiveness of development and the quality of the final game. By adopting a clear and logical structure for assets, such as keeping Controllers and Managers inside the Scripts folder, developers can optimize the development workflow. This structure also aids in managing and expanding the project as it grows, making it easier to locate, update, and scale individual components.
 
Last edited:

Top