using Unity.Entities;
namespace MyNamespace.System
{
public partial class BrokenSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.ForEach((MyComponent c) => {}).Run();
}
}
public struct MyComponent : IComponentData { }
}
Beware that in a big project this can be quite a nightmare. It means that if you have something like Views.Interaction and Player.Interaction, with a foreach referring both, codegen will break.
The only workaround I found was to give unique names to my namespaces and never use System in any part of the namespace.
Plural will work because it doesn’t clash with System. And the second might be a viable long term workaround if this behaviour is by design. Still, that’s how Rider and VS functions (putting usings at top of the file, outside namespace).
The bug can be reproduced in an empty project by simply doing a ForEach inside a namespace containing System. That could be My.System.Something or Something.System, as long as System is somewhere, it will break codegen.
I had this issue as well with the namespace EnvironmentRenderingSystem, but weirdly completely removing the entities package from the project and reinstalling it fixed the problem…