QFramework Documentation

repository·master·Indexed 26 days ago

https://github.com/liangxiegame/qframework

A lightweight Unity architecture framework based on SOLID principles, supporting DDD, Event-Driven, Data-Driven, and CQRS patterns. It consists of a core architecture (QFramework.cs) implementing MVC and IOC, and a suite of Toolkits including UIKit for UI management, ResKit for resources, AudioKit, and CoreKit (featuring JsonKit, EventKit, and IOCKit). Compatible with Unity 2018.4.x and Unity 6.x.

Tokens
79.6K
Snippets
133
Records
318
Agent score
85%

What's inside QFramework

  1. Overview of QFramework.cs Architecture

    master

    QFramework.cs is a simple, powerful, and easy-to-learn system design architecture. It is designed to be lightweight (source code under 1000 lines) and follows SOLID principles.

    Key Architectural Features:

    • MVC-based: Uses Model-View-Controller patterns.
    • Layered Design: Promotes separation of concerns through layering.
    • Optional Support for:
      • CQRS (Command Query Responsibility Segregation)
      • Event-driven architecture
      • Data-driven design
      • IOC (Inversion of Control) modularization
      • DDD (Domain-Driven Design)
    • Design Compatibility: Supports paper-based design using standard UML.
    • Portability: The architectural patterns learned can be applied to other languages and platforms independently of the framework.
  2. Introduction to Res Kit

    master

    Res Kit is a resource management and rapid development solution for Unity. It provides a unified API to load resources from various locations including dataPath, Resources, StreamingAssets, PersistentDataPath, and network sources.

    Key features:

    • Reference Counting: Simplifies resource loading and unloading.
    • Development Workflow Support: Supports loading directly from dataPath during development and using AssetBundles during testing/production.
    • Constant Generation: Can generate resource name constants to reduce typos.
    • Async Loading: Supports asynchronous loading queues.
    • Simplified AssetBundle API: Allows loading resources by name alone without explicitly specifying the AssetBundle name.
  3. Overview of QFramework Core and Toolkits

    master

    QFramework is a progressive, rapid development framework for Unity games and applications. It consists of two main components:

    1. QFramework.cs (Core Architecture): A lightweight (< 1000 lines) architecture implementing MVC, IOC, layered support, and CQRS. It follows SOLID principles and supports DDD (Domain-Driven Design).
    2. QFramework.Toolkits: A comprehensive suite of development tools including:
      • UIKit: UI and GameObject management, code generation, and panel stacking.
      • ResKit: Resource management with AssetBundle simulation, reference counting, and unified APIs for Resources/Network/Custom sources.
      • AudioKit: Audio management for BGM, Voice, and Sound Effects.
      • CoreKit: A collection of utility kits including ActionKit (sequences), CodeGenKit (code generation), EventKit (event handling), IOCKit (dependency injection), PoolKit (object pooling), and more.
  4. Overview of QFramework and Toolkits

    master

    QFramework is a progressive, rapid development framework for Unity suitable for any game or application project. It consists of two main parts:

    1. QFramework.cs (Core Architecture): A lightweight (< 1000 lines) architecture implementing MVC, IOC, layered support, and CQRS. It follows SOLID principles and supports DDD (Domain-Driven Design).
    2. QFramework.Toolkits: A comprehensive suite of development tools including:
      • UIKit: UI and View management (code generation, hierarchy management, stack management).
      • ResKit: Resource management (AssetBundle simulation, reference counting, unified API for Resources/Network/Custom sources).
      • AudioKit: Audio management (BGM, Voice, Sound Effects).
      • CoreKit: A collection of utility kits:
        • ActionKit: Action sequence execution.
        • CodeGenKit: Code generation and auto-serialization.
        • EventKit: Event system (Class, String, Enum, Signal based).
        • FluentAPI: Chainable API extensions for Unity/C#.
        • IOCKit: Dependency Injection container.
        • LocaleKit: Localization and multi-language support.
        • LogKit: Logging utilities.
        • PackageKit: Package management for framework/plugin updates.
        • PoolKit: Object pooling (including List and Dictionary pools).
        • SingletonKit: Singleton utilities.
        • TableKit: Table-based data structures.
  5. Overview of QFramework Architecture

    master

    QFramework is a simple, powerful, and easy-to-use system design architecture for Unity. It is built on several core principles and optional patterns to help developers design scalable game systems.

    Core Features:

    • MVC-based: Follows the Model-View-Controller pattern.
    • Layered Architecture: Promotes separation of concerns through distinct layers.
    • SOLID Principles: Adheres to standard object-oriented design principles.
    • Lightweight: The core source code is under 1000 lines.

    Optional Supported Patterns:

    • CQRS (Command Query Responsibility Segregation): For separating read and write operations.
    • Event-Driven: For decoupled communication between components.
    • Data-Driven: For managing game logic through data.
    • IOC (Inversion of Control): For modularity and dependency injection.
    • DDD (Domain-Driven Design): For complex business logic modeling.
  6. Overview of ResKit Resource Management

    master

    ResKit is a resource management and rapid development solution. Key features include:

    • Unified API for loading resources from dataPath, Resources, StreamingAssets, PersistentDataPath, or networks.
    • Reference counting to simplify loading and unloading.
    • Support for different development stages (e.g., loading directly from dataPath during development vs. AssetBundles).
    • Ability to generate constant code for resource names to prevent typos.
    • Asynchronous loading queue support.
    • Simplified AssetBundle loading via resource names instead of requiring the AssetBundle name explicitly.
  7. Introduction to UI Kit

    master

    UI Kit is a solution for interface management and rapid development within QFramework. Its key features include:

    • Interface Management: Centralized control of UI panels.
    • Layer Management: Organized UI hierarchy.
    • Code Generation & Component Auto-binding: Uses a ViewController based system to automatically bind UI components to code.
  8. Overview of QFramework.Toolkits modules

    master

    QFramework.Toolkits is a progressive, out-of-the-box rapid development framework for Unity. It consists of several specialized kits:

    • UIKit: UI and GameObject rapid development and management (includes UI stack, layer management, and code generation).
    • ResKit: Resource management supporting AssetBundle (with simulation mode), Resources, Network, and custom sources, using a reference counting model.
    • AudioKit: Audio management providing APIs for Background Music (BGM), Voice, and Sound Effects (SFX).
    • CoreKit: A collection of code utilities:
      • ActionKit: Action sequence execution system.
      • CodeGenKit: Code generation and automatic serialization/assignment.
      • EventKit: Event tools based on classes, strings, enums, and signals.
      • FluentAPI: Static extension wrappers for Unity and C# APIs (chainable).
      • IOCKit: Dependency injection container.
      • LocaleKit: Localization and multi-language tools.
      • LogKit: Logging utilities.
      • PackageKit: Package management for updating the framework and plugins.
      • PoolKit: Object pooling (including ListPool and Dictionary Pool).
      • SingletonKit: Singleton utilities.
      • TableKit: Table-based data structure utilities.
  9. Overview of QFramework.Toolkits

    master

    QFramework.Toolkits is an out-of-the-box, progressive, and rapid development framework designed for Unity3D. It is intended as a first framework for developers with little framework experience, solo developers, and beginners. It provides a collection of specialized toolkits to solve common game development challenges with low learning and integration costs.

    Key components include:

    • UIKit: Solutions for UI and GameObject rapid development, management, and layering.
    • ResKit: Resource management supporting AssetBundles (with simulation mode), Resources, network, and custom sources, using a reference-counting model.
    • AudioKit: Audio management for background music, voices, and sound effects.
    • CoreKit: A collection of code utilities including:
      • ActionKit: Action sequence execution system.
      • CodeGenKit: Code generation and automatic serialization/assignment.
      • EventKit: Event tools based on classes, strings, enums, and signals.
      • FluentAPI: Chainable API wrappers for common Unity and C# APIs.
      • IOCKit: Dependency injection container.
      • LocaleKit: Localization and multi-language tools.
      • LogKit: Logging utilities.
      • PackageKit: Package management for framework and plugin updates.
      • PoolKit: Object pooling (including ListPool and Dictionary Pool).
      • SingletonKit: Singleton utilities.
      • TableKit: Table-based data structure tools.
  10. Features of JsonKit

    master

    JsonKit provides several specialized features for Unity development:

    • Encoding/Decoding: Convert between JSON strings and JSONObject structures.
    • Interoperability: Works with Dictionary and WWWForm.
    • Performance: Optimized parse/stringify with minimal garbage; includes an asynchronous stringify for large datasets to prevent frame drops.
    • Parsing Controls: MaxDepth parsing to skip nested data; strict mode to enforce valid JSON formatting.
    • Special Types: Baked type for storing stringified data within parsed objects; support for Infinity and NaN.
    • Utilities: JSONTemplates for serializing Unity types like Vector3 and Matrix4x4; JSONChecker window for testing.
    • Data Access: Random access via int or string indices; ToString() with a "pretty" flag for formatted output.
  11. QFramework Architectural Layers Overview

    master

    QFramework follows a layered architecture to separate concerns. The four primary layers are:

    • Presentation Layer (IController): Handles UI and user interaction (typically MonoBehaviour).
    • System Layer (ISystem): Handles complex business rules and logic (inherits AbstractSystem).
    • Data Layer (IModel): Manages state and data storage (inherits AbstractModel).
    • Utility Layer (IUtility): Provides reusable tools and services (implements IUtility).

    Additionally, the framework uses Commands (AbstractCommand) to handle interaction logic and Events to handle state changes, following a simplified CQRS pattern: Command -> Model -> State Changed Event.

  12. Summary of UIKit Core Features

    master

    UIKit provides a comprehensive solution for UI management and rapid development in Unity. The core capabilities include:

    • Code Generation: Automated generation of UIPanel and UIElement code.
    • Panel Lifecycle Management: Built-in lifecycle hooks for managing UI states.
    • Testing Tools: Tools for generating test scenes for UIPanel.
    • Customization: Support for custom loading interfaces.
    • Core APIs: Methods for opening, closing, and managing the UI stack and resolution.