#how to communicate between ISystem and monobehaviour

1 messages · Page 1 of 1 (latest)

unborn sundial
#

how do I tirgger a function using monobehaviour script to instantiate a cube for example
I don't want to use SystemBase as it will not allow me use burst

stuck prawn
#

monobehaviour = no burst as well

#

there's a burst compatible api to instantiate game objects

#

GameObject.InstantiateGameObjects

unborn sundial
#

I want to do something like this : ```

using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using Unity.Transforms;
using UnityEngine;
using Unity.Mathematics;
using Unity.Burst;

public partial struct SpawnCubeSystem : ISystem
{

[BurstCompile]
public void OnUpdate(ref SystemState state)
{
    if (MonoBehaviour send a trigger)
    {
        foreach (var spawnCubeComponent in SystemAPI.Query<RefRO<SpawnCubeComponent>>())
        {

            for (int y = 0; y < 1000; y++)
            {
                for (int x = 0; x < 1000; x++)
                {
                    Entity clone = state.EntityManager.Instantiate(spawnCubeComponent.ValueRO.Prefab);
                    state.EntityManager.SetComponentData(clone, LocalTransform.FromPosition(new float3(x * 0.25f, 0, y * 0.25f)));
                }
            }


        }
    }
}

}