Not sure what I am doing wrong here, I am attempting to change the mesh that my MeshRenderer Component is using, it will work for a few frames then my console gets spammed with the above error.
line that is causing the error
mesh = entityManager.GetSharedComponentData(m_Data.animator*.entity);*
full script
```
*public struct Data
{
public int Length;
public ComponentDataArray animator;
[ReadOnly] public SharedComponentDataArray renderer;
}
[Inject] private Data m_Data;
protected override void OnUpdate()
{
for(int i = 0; i < m_Data.Length; i++)
{
mesh = entityManager.GetSharedComponentData(m_Data.animator[i].entity);
mesh.mesh = idleMesh[CurrentFrame];
entityManager.SetSharedComponentData(m_Data.animator[i].entity, mesh);
}
currentFrame = (currentFrame >=100) ? 0 : currentFrame = currentFrame += 1;
}*
* *here is how I am spawning the entity* *
-
void OnDestroy()actors = new NativeArray<Entity>(100, Allocator.Persistent); Entity[] characters = new Entity[actors.Length]; var entityManager = World.Active.GetOrCreateManager<EntityManager>(); var protoType = entityManager.Instantiate(umaPrefab); entityManager.AddComponentData(protoType, new Position { Value = new float3(0, 0, 0) }); entityManager.AddComponentData(protoType, new Rotation { Value = new quaternion(-90, 0, 180, 0) }); entityManager.AddComponentData(protoType, new TransformMatrix()); entityManager.AddComponentData(protoType, new AnimatorComponent { }); renderer = umaPrefab.transform.Find("UMARenderer").GetComponent<SkinnedMeshRenderer>(); entityManager.AddSharedComponentData(protoType, new MeshRenderComponent { mesh = renderer.sharedMesh, material = renderer.sharedMaterial}); entityManager.Instantiate(protoType, actors); entityManager.DestroyEntity(protoType); actors.CopyTo(characters); for (int i = 0; i < characters.Length; ++i) { entityManager.SetComponentData(characters[i], new Position { Value = new float3(1 * i, 0, 1 * (i/10)) }); entityManager.SetComponentData(characters[i], new Rotation { Value = new quaternion(0, 0, 0, 0) }); entityManager.SetComponentData(characters[i], new AnimatorComponent { entity = characters[i] }); }
{
actors.Dispose();
}*
```