Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active November 7, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/b433b321f8fad0457d0e6fd1e92fcec0 to your computer and use it in GitHub Desktop.
Save tsubaki/b433b321f8fad0457d0e6fd1e92fcec0 to your computer and use it in GitHub Desktop.
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