I’m trying to migrate my AnimatorSystem to the new without burst JobComponentSystem, and while writing the code was quite quick and compiled just fine, turns out it doesn’t work at runtime. I get the following error: BadImageFormatException: Method with open type while not compiling gshared
I believe it may be due to the fact that I have a generic system that I override. The error is thrown in the implementations of the following code:
using Unity.Entities;
using Unity.Jobs;
using UnityEngine;
namespace Parabole.AnimatorSystems
{
[UpdateInGroup(typeof(PresentationSystemGroup))]
[AlwaysSynchronizeSystem]
public abstract class SetBufferElementSystem<TBufferElementData> : JobComponentSystem
where TBufferElementData : struct, IBufferElementData
{
private EntityQueryDesc queryDesc;
private EntityQuery query;
private bool hasInitialized = false;
protected override void OnCreate()
{
queryDesc = new EntityQueryDesc
{
All = new[]
{
ComponentType.ReadOnly<DotsAnimator>(),
ComponentType.ReadWrite<TBufferElementData>()
}
};
query = GetEntityQuery(queryDesc);
RequireForUpdate(query);
}
protected override void OnStartRunning()
{
if (!hasInitialized)
{
Entities.WithoutBurst().ForEach((Entity entity, DotsAnimator dotsAnimator) =>
{
EntityManager.AddBuffer<TBufferElementData>(entity);
})
.Run();
hasInitialized = true;
}
}
protected override JobHandle OnUpdate(JobHandle inputDependencies)
{
Entities.WithoutBurst().ForEach((DynamicBuffer<TBufferElementData> buffer, DotsAnimator dotsAnimator) =>
{
if (buffer.Length > 0)
{
for (var i = 0; i < buffer.Length; i++) SetElement(i, buffer[i], dotsAnimator);
buffer.Clear();
}
})
.Run();
return default;
}
protected abstract void SetElement(int index, TBufferElementData elementData, DotsAnimator dotsAnimator);
}
}
I don’t really understand the error itself. Also please don’t mind the initialization code, it’s a bit of a hack for now as I do not know exactly where I should be doing these things .