Skip to main content

Use Extend Codegen CLI to generate Unreal SDK Plugin for Extend Service Extension

Last updated on November 14, 2023

Overview

The Extend Codegen CLI is a tool for generating code from an OpenAPI 2.0 JSON according to the template pack which is used with it. The OpenAPI 2.0 JSON may come from custom service, such as from Extend Service Extension. The template pack consists of jinja templates and a makefile to invoke Extend Codegen CLI and the jinja templates for generating code.

This particular template pack is used to generate a custom service module for the AccelByte Unreal SDK. It will allow developers to interact with their custom service APIs more effectively by using AccelByte SDk, which offers enhanced functionality, such as login capabilities, token refresh, token validation, and HTTP request retries. All of these features are included to enable developers to concentrate on their specific objectives.

Prerequisites

  1. Based on your operating system, you will need the following tools:

    a. Linux Ubuntu 20.04 (or Windows 10 WSL2)

     i. bash

    ii. make

    iii. Docker v23.x

    b. Windows 10

     i. [Cygwin](https://github.com/AccelByte/extend-codegen-cli/blob/master/windows/INSTALLING_CYGWIN.md)

    ii. Docker v23.x
    info

    Support for macOS may be available soon.

  2. The latest version of the Extend Codegen CLI binary for your operating system. For Linux, you may have to use chmod +x accelbyte-codegen-linux_amd64 to allow the file to be executed.

    info

    Some examples demonstrate the use of the accelbyte-codegen executable file, with the filename potentially varying in your specific scenario such as accelbyte-codegen-linux_amd64 or accelbyte-codegen-windows_amd64, depending on your operating system.

  3. The latest version of the template pack zip.

  4. The AccelByte Unreal SDK.

  5. A valid Open API 2.0 JSON file from your custom service.

Generate Unreal SDK Plugin for Extend Service Extension

  1. Copy the valid Open API 2.0 JSON or YAML file(s) from your custom service into a folder in your Unreal project, for example, /path/to/unreal/project/spec.

    important

    The template pack uses the OpenAPI 2.0 JSON file name as an identifier for your service. You can rename the file according to your preferences, but please use all lowercase alphabets (a-z) to avoid issues when generating code.

    Duplicate the JSON or YAML file(s) from your custom service(s) into three more directories (Client, GameServer, Models) under the folder you've chosen.

    /path/to/unreal/project/
    ├── ...
    └── spec/
    ├── Client/
    │ └── guild.json <
    ├── GameServer/
    │ └── guild.json <
    └── Models/
    └── guild.json <
  2. Unzip the contents of the template pack zip file you downloaded. Next, navigate inside the folder where a Makefile file is located and execute the following command:

    make all \
    CODEGEN_PATH=/path/to/my/accelbyte-codegen \
    PROJECT_PATH=/path/to/unreal/project/Plugins \
    SPEC_PATH=/path/to/unreal/project/spec
    important

    If the Plugins folder do not exist in your Unreal project, you'll have to create it manually.

    Output

    * copied ./res/AccelByteUe4SdkCustomization into Source/AccelByteUe4SdkCustomization
    * copied spec/Client into Source/AccelByteUe4SdkCustomization/spec/Client
    * copied spec/GameServer into Source/AccelByteUe4SdkCustomization/spec/GameServer
    * copied spec/Models into Source/AccelByteUe4SdkCustomization/spec/Models
    * generated guild Client API Source
    * generated guild Client API Header
    * generated guild GameServer API Source
    * generated guild GameServer API Header
    * generated guild Models
    { "services": [ { "file_stem": "guild", "path": "guild" } ] }
    { "services": [ { "file_stem": "guild", "path": "guild" } ] }
    * generated Client Config Source
    * generated Client Config Header
    * generated GameServer Config Source
    * generated GameServer Config Header
  3. Add AccelByteUe4SdkCustomization into PublicDependencyModuleNames of your project .Build.cs file.

    PublicDependencyModuleNames.AddRange(new string[] {, "AccelByteUe4SdkCustomization" });
  4. Add the AccelByteUe4SdkCustomization module in the AccelByteUe4Sdk.uplugin file.

    {
    "Name": "AccelByteUe4SdkCustomization",
    "Type": "Runtime",
    "LoadingPhase": "PreDefault"
    }