Instantly share code, notes, and snippets.

Embed
What would you like to do?
using Unity.Entities;
[InternalBufferCapacity(4)]
public struct EntityBuffer : IBufferElementData
{
public Entity entity;
}
using Unity.Entities;
using UnityEngine;
public class FollowTargets : MonoBehaviour
{
[SerializeField] GameObjectEntity[] entities;
void Start ()
{
EntityManager entityManager = World.Active.GetExistingManager<EntityManager>();
Entity entity = GetComponent<GameObjectEntity>().Entity;
entityManager.AddBuffer<EntityBuffer>(entity);
DynamicBuffer<EntityBuffer> buffer = entityManager.GetBuffer<EntityBuffer>(entity);
for (int i=0; i<entities.Length; i++)
{
buffer.Add( new EntityBuffer() { entity = entities[i].Entity });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment