Last active
November 7, 2018 14:11
-
-
Save tsubaki/b433b321f8fad0457d0e6fd1e92fcec0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Unity.Entities; | |
[InternalBufferCapacity(4)] | |
public struct EntityBuffer : IBufferElementData | |
{ | |
public Entity entity; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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