Arch.AOT.SourceGenerator
Arch.AOT.SourceGenerator, making arch fully AOT compatible.
Arch itself in its current state is mostly native AOT compatible. However, it still requires some boilerplate-code, especially the registration of components. That's where this extension comes into play.
Example
You could register all your components by yourself. But that's a lot of work. AOT.SourceGenerator got you, just mark your components with a [Component]
attribute like this:
[Component]
public struct Velocity{ ... }
[Component]
public struct Transform{ ... }
And it will generate a registration-module like this:
namespace Arch.AOT.SourceGenerator
{
internal static class GeneratedComponentRegistry
{
[ModuleInitializer]
public static void Initialize()
{
ArrayRegistry.Add<Velocity>();
ComponentRegistry.Add(new ComponentType(ComponentRegistry.Size + 1, typeof(Transform), Unsafe.SizeOf<Transform>(), false);
}
}
}
Notice the [ModuleInitializer]
? The generated class will automatically be called upon application start to register the components.
Last updated
Was this helpful?