Search Unity

Changing Particle texture in particle system in c#

Discussion in '2D' started by JelleTorres, Feb 13, 2020.

  1. JelleTorres

    JelleTorres

    Joined:
    Apr 25, 2018
    Posts:
    9
    I have 1 particle system and 4 different sprites
    Depending on some input in want to change the shape op the particles trough script.

    At this time I can set the shape of the particle by dragging one of the sprites in to the particle texture (shader: mobile/particles/Additive) SEE IMAGE*
    I could make 4 different particle systems but that doesn't scale very wel if I want to add more or if I want to change the properties of the all particle systems.

    id like to do something like:

    public Sprite[] imgs;
    public Gameobject particleSystem;

    public void SetParticleShape(int n)
    {
    Gameobject obj = instanciaste(particleSytem, transform.position, quarternion.identity);
    obj.SHADER_TEXTURE = imgs[n];
    }

    Schermafbeelding 2020-02-13 om 17.45.41.png
     

    Attached Files:

    Last edited: Feb 13, 2020