Use Extend Codegen CLI to generate Unreal SDK Plugin for Extend Service Extension
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
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.xb. Windows 10
i. [Cygwin](https://github.com/AccelByte/extend-codegen-cli/blob/master/windows/INSTALLING_CYGWIN.md)
ii. Docker v23.x備考Support for macOS may be available soon.
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.備考Some examples demonstrate the use of the
accelbyte-codegen
executable file, with the filename potentially varying in your specific scenario such asaccelbyte-codegen-linux_amd64
oraccelbyte-codegen-windows_amd64
, depending on your operating system.The latest version of the template pack zip.
A valid Open API 2.0 JSON file from your custom service.
Generate Unreal SDK Plugin for Extend Service Extension
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
.importantThe 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 <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/specimportantIf 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 HeaderAdd
AccelByteUe4SdkCustomization
intoPublicDependencyModuleNames
of your project.Build.cs
file.PublicDependencyModuleNames.AddRange(new string[] { …, "AccelByteUe4SdkCustomization" });
Add the
AccelByteUe4SdkCustomization
module in theAccelByteUe4Sdk.uplugin
file.{
"Name": "AccelByteUe4SdkCustomization",
"Type": "Runtime",
"LoadingPhase": "PreDefault"
}