I know that Monobehaviors can be associated with an Entity using the conversion tool. I am trying to do it manually without success.
code
using UnityEngine;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
public class PolygonCreateLineRendererSystem : SystemBase
{
EndSimulationEntityCommandBufferSystem m_EndSimulationEcbSystem;
protected override void OnCreate()
{
base.OnCreate();
m_EndSimulationEcbSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
}
protected override void OnUpdate()
{
//var ecb = m_EndSimulationEcbSystem.CreateCommandBuffer();
Entities
.WithoutBurst()
.WithAll<Polygon, PolygonCreateLineRendererTag>()
.ForEach((Entity entity, DynamicBuffer<PolygonPoint> buffer) => {
var lr = new LineRenderer();
lr.positionCount = buffer.Length;
for(var i = 0; i < buffer.Length; i++)
{
Debug.Log(buffer[i].Value);
lr.SetPosition(i, buffer[i].Value);
}
//ecb.SetComponent(entity, lr);
World.EntityManager.SetComponentData<LineRenderer>(entity, lr);
World.EntityManager.RemoveComponent<PolygonCreateLineRendererTag>(entity);
Debug.Log("PolygonCreateLineRendererSystem hit!");
})
.Run();
//.Schedule();
//m_EndSimulationEcbSystem.AddJobHandleForProducer(this.Dependency);
}
}