コード例 #1
0
        protected override void OnUpdate()
        {
            HighlightCellPrefab  highlightPrefab  = GetSingleton <HighlightCellPrefab>();
            EntityCommandBuffer  ecb              = barrier.CreateCommandBuffer();
            NativeArray <Entity> highlightedCells = HighlightCell.List();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         in HexCoordinates coordinates,
                         in CommandRemoveHighlight commandRemoveHighlight
                         ) => {
                foreach (var highlightedCell in highlightedCells)
                {
                    HexCoordinates highlightedCoordinates = EntityManager.GetComponentData <HexCoordinates>(highlightedCell);

                    if (coordinates == highlightedCoordinates)
                    {
                        ecb.DestroyEntity(highlightedCell);
                    }
                }

                ecb.DestroyEntity(entity);
            }).Run();
コード例 #2
0
        protected override void OnUpdate()
        {
            HighlightCellPrefab highlightPrefab = GetSingleton <HighlightCellPrefab>();
            EntityCommandBuffer ecb             = barrier.CreateCommandBuffer();

            Entities
            .WithoutBurst()
            .ForEach((
                         Entity entity,
                         in CommandCreateHighlight commandCreateHighlight,
                         in HexCoordinates coordinates
                         ) => {
                HighlightCell.Create(ecb, highlightPrefab, coordinates);

                ecb.DestroyEntity(entity);
            }).Run();