Search Unity

Spawn Particle System from dots Job

Discussion in 'Entity Component System' started by elJoel, Mar 11, 2020.

  1. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    So I have a Prefab with a Particle System on it. I want to spawn a simple GameObject with this Particle System in it from a Job.

    How do I do it?

    I tried adding the Convert To Entity Script with the "Convert And Inject Game Object" option. And spawning like this:
    Code (CSharp):
    1.                 var instance = commandBuffer.Instantiate(nativeThreadIndex, explodesOnCollisionComponent.Explosion);
    2.                 commandBuffer.SetComponent(nativeThreadIndex, instance, new Translation
    3.                 {
    4.                     Value = translation.Value
    5.                 });
    6.  
    But this only adds the Entity without the Particle System.