Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 771 Bytes

code-on-load.md

File metadata and controls

36 lines (29 loc) · 771 Bytes

Run code on module load

The most common way to inject custom features to game or engine is via plugins but you can also run custom chunks of code when code assembly gets loaded by the engine:

// Use ModuleInitializer attribute on static class - every static, void and parameterless method will be invoked after C# module gets loaded.

using FlaxEngine;

[ModuleInitializer]
static partial class Initializer
{
    static void Init()
    {
        Debug.Log("Hello!");
    }
}
// Use static variable which constructor will be called when C++ module gets loaded.

#include "Engine/Core/Log.h"

struct Initializer
{
    Initializer()
    {
        LOG(Info, "Helllo!");
    }
};

Initializer Init;