Arch-ECS
💬 Join the discord!☕ Buy us a coffee!
  • 🌄Why Arch?
  • 📖Documentation
    • Concepts
    • World
    • Entity
    • Query
    • Archetypes & Chunks
    • Optimizations
      • Query-Techniques
      • Pass on data
      • Batch and Bulk
      • PURE_ECS
      • Multithreading
      • EntityData
    • Utilities
      • Component Registration
      • Non-generic API
      • CommandBuffer
      • Events
      • Dangerous Extensions
  • 🧩Extensions
    • Arch.Extended
      • Arch.System
      • Arch.System.SourceGenerator
      • Arch.EventBus
      • Arch.AOT.SourceGenerator
      • Arch.LowLevel
      • Arch.Persistence
      • Arch.Relationships
  • 💡Examples & Guidelines
    • Arch.Samples
    • Entities in Query
    • Structural changes
  • Unity
  • 🎮Projects using Arch
    • Skylandkingdoms
    • Cubetory
    • SS14
    • EquilibriumEngine-CSharp
    • Rougelite-Survivor
  • ✏️Misc
    • Roadmap
    • FAQ
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Extensions
  2. Arch.Extended

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.

PreviousArch.EventBusNextArch.LowLevel

Last updated 2 months ago

Was this helpful?

If you prefer to do the whole thing manually, have a look ...

🧩
here