Unity – Zenith Framework

A C# project designed to help both new and experienced developers kickstart their projects quickly, while ensuring scalability, maintainability, and reliability as their codebase grows, causing less headache to developers, allowing them to code more creatively and faster. Inspired by industry-renowned books like Clean Architecture, Clean Code, and Game Programming Patterns, combined with hands-on experiences from myself and insights from talented friends in the game development industry.

Making Of: The Story Behind Zenith Framework

The idea for the Zenith Framework came to life during the Melbourne Games Week 2024, through engaging conversations with passionate developers, designers, and architects. We discussed Unity best practices, effective game architecture, and C# optimizations. After countless conversations, a clear vision emerged:

What if there was a framework that minimized late-stage project limitations, reduced time spent on refactoring and bug-fixing, and promoted clean, reusable code for long-term scalability?

The result is the Zenith Framework — a project built to empower developers to focus more on creative problem-solving or features and less on technical debt.

This project was developed independently using Unity and Rider C# IDE as core tools, with references from Unity documentation and renowned code architecture books. All the architectures were thoughtfully designed using draw.io and refined through invaluable feedback from industry professionals, to whom I am deeply grateful!

Project: https://github.com/gabrielgborges/zenith-framework

Introduction

Why Use Zenith Framework?

When developing medium-to-large-scale Unity projects, maintaining clean, modular, and scalable code becomes challenging. The Zenith Framework is built on principles derived from Clean Architecture to solve this problem, ensuring:

  • Rapid Development: Start your projects with a solid architecture and ready-to-use systems, reducing the setup time.
  • Maintainability: Easily locate and fix bugs.
  • Scalability: Expand your game systems and add new features without breaking existing functionality.
  • Reusability: Create reusable components that can speed up future projects.

The framework utilizes Component and ServiceLocator architectures to keep your code decoupled and flexible. It emphasizes creating modular systems, enabling developers to replace or extend functionality without widespread code changes.

Integer lacinia sollicitudin massa. Cras metus. Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante.

Core Principles

Zenith Framework is grounded in these three architectural principles:

  1. Common Closure Principle:

    • Group classes that change for the same reason to simplify maintenance.
  2. Common Reuse Principle:

    • Avoid dependencies on classes you don’t use.
  3. Reuse/Release Equivalence Principle:

    • Group classes to maximize reusability and minimize unnecessary coupling.

These principles ensure that your code remains clean, adaptable, and aligned with industry standards.

alt text

Reference: “Clean Architecture: A Craftsman’s Guide to Software Structure and Design” by Robert C. Martin.

Tip:

Treat the Zenith Framework like a tool—test it thoroughly before fully integrating it into your project. A long-term relationship starts with a few good dates! 😉


Key Concepts and Components

1. Service

Service is a core system that provides functionality widely used across your game. Examples include:

  • Object Pooling
  • VFX Spawner
  • Time Manager
  • Screen Manager

Why Services? Services are accessed via the ServiceLocator and use interfaces to enforce limited, controlled access. This design ensures that:

  • Complex logic can be refactored without affecting dependent code.
  • Systems remain decoupled for easier maintainability, testing and bugfixing.
  • Replacement services can be easily swapped in with minimal changes.

Example: Switching from Asset Bundles to Addressables in your Object Pooling system requires only creating a new implementation of the same interface.

Before refactor:

alt text

After refactor:

alt text


2. Entity

Entity is a MonoBehaviour that manages events, data, and states within a specific context. It serves as the bridge between the Services and Components.

Entitys should:

  • Hold state information relevant to a feature or system.
  • Act as a hub for other Components to update or retrieve state data.

General application example:

alt text


3. Component

Component implements the primary logic of a feature while interacting with Services or Entitys. Components are designed to:

  • Focus on a single feature per class.
  • Be reusable across different systems or contexts.

Relationships with Entitys:

  1. Update the Entity’s state when necessary.
  2. Implement the features associated with the Entity.

alt text

This separation ensures that changes to a specific feature only affect the associated Component, leaving Entitys and Services intact.

Example: A HealthComponent manages the health logic, while the HealthEntity tracks and communicates health states to other systems.


Additional Services

The Zenith Framework includes additional ready-to-use services such as:

Screen Service: Handle all the instantiation, loading and management of UI Screens inside Unity, decoupling this process.

Event Service: Global event manager that enables decoupled and fast communication between classes in different Assemblies.

Object Pooling: Efficiently reuse objects to reduce memory allocations and improve performance. More Services Coming Soon! (Stay tuned for additional services and documentation.)

contact

 

Let’s Get in Touch

I love to connect with fun and talented people! Please don’t hesitate to get in touch for a no obligations chat about yours or any other project.

Please enable JavaScript in your browser to complete this form.