Code¶
4 tools for the project's C++: compiling the editor's modules with Live Coding, the compiler's errors, and adding a class.
Back to the index.
create_cpp_class¶
Additive Refused during PIE
Write the header and source of a new UCLASS into one of the project's C++ modules, derived from a native class (default Object). It writes the two files and nothing else: no project-file regeneration, no compile, no reload.
Refuses a class name already in use (in memory or as a header of the module), an unknown module, a parent that is unknown, a Blueprint class, an interface or not exported to other modules, and a project without a C++ module (a Blueprint-only project gets its first module from the editor's New C++ Class). Refused during Play-in-Editor without force.
The class is usable only once the module is built: needs_restart is true because a new UCLASS patched in by Live Coding is not reliable. Close the editor, build the editor target, and reopen it.
| Parameter | Type | Required | Description |
|---|---|---|---|
class_name |
string | yes | Required. The class name without its U or A prefix, e.g. "MyActor". |
parent_class |
string | no | Optional native parent class: "Object", "Actor", "ActorComponent", "AActor", or a path like "/Script/Engine.Actor". Default "Object". |
module_name |
string | no | Optional project module to add the class to. Default the primary game module (the one named after the project). |
class_location |
string | no | Optional "public" (header under Public, exported with MODULE_API) | "private" (both files under Private). Default "public". A module without Public and Private folders keeps both files in its folder. |
sub_path |
string | no | Optional folder under Public/Private (or the module folder), e.g. "Gameplay/Items". |
Returns: { created: bool, class_name: string, parent_class: string, module_name: string, header_path: string, source_path: string, needs_compile: bool, needs_restart: bool, note: string }
get_cpp_compile_status¶
Read-only
The state of the last compile start_cpp_compile requested in this editor session: running or finished, the result, and the compiler's errors and warnings with file, line and column, plus the state of Live Coding. With no compile started it answers has_compile false and still reports live_coding.
result is "success", "no_changes", "failure" or "cancelled" once finished. errors and warnings come from the UnrealBuildTool log of that compile (Live Coding's console keeps the compiler output out of the editor log), or from hot reload's output; output_tail holds what they were read from, and ubt_log_path the file, for the lines the parser does not know.
| Parameter | Type | Required | Description |
|---|---|---|---|
max_results |
number | no | Optional cap on the entries of errors and of warnings. Default 100. |
Returns: { has_compile: bool, running?: bool, finished?: bool, result?: string, mode?: string, errors?: [{file, line, column, code, message}], warnings?: [{file, line, column, code, message}], error_count?: int, warning_count?: int, elapsed_seconds?: number, output_tail?: string, ubt_log_path?: string, log_cursor_before?: int, note?: string, live_coding: {available, enabled, started, compiling, enabled_by_default?, reason?} }
set_live_coding_enabled¶
Destructive Idempotent
Turn Live Coding on or off for this editor session, as the Live Coding toggle does; on starts its console the first time, which start_cpp_compile needs. The project's default (Editor Preferences) is not changed.
| Parameter | Type | Required | Description |
|---|---|---|---|
enabled |
boolean | yes | Required. true to enable Live Coding for this session, false to disable it. |
Returns: { enabled: bool, started: bool, note: string }
start_cpp_compile¶
Destructive Refused during PIE
Compile the C++ modules of the running editor and patch them in, as the editor's Live Coding compile button does; returns as soon as the compile is requested, so poll get_cpp_compile_status for the result and the compiler's errors.
One compile at a time: a call while one runs answers already_running true and starts nothing. Live Coding has no cancel. A patch reinstances live objects of the changed classes, so it is refused during Play-in-Editor without force.
mode "auto" (default) uses Live Coding when it has started in this session and refuses otherwise with the reason; "live_coding" also starts Live Coding first, like the button; "hot_reload" compiles without Live Coding, only when Live Coding has not started, and can corrupt the defaults of Blueprints built on the reloaded classes, so auto never picks it.
| Parameter | Type | Required | Description |
|---|---|---|---|
mode |
string | no | Optional "auto" | "live_coding" | "hot_reload". Default "auto". |
Returns: { compile_started: bool, already_running: bool, mode: string, log_cursor_before?: int, note: string }