Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Prefab is set InActive when ParticleSystem.Play()

Discussion in 'Prefabs' started by rosco_y, Dec 7, 2022.

  1. rosco_y

    rosco_y

    Joined:
    Aug 3, 2016
    Posts:
    31
    I have a prefab "cube" which contains a simple particle system.

    I have it exposed as
    Public ParticleSystem SuccessParticles {get;set;}

    in my code I call cube.SuccessParticles.Play();, and the particle system plays fine, but as soon as it is finished my cube's Active state is set to false.
    The same thing happens when I set "PLay on Awake" to true.

    I wonder if you can tell me what I've done incorrectly?
     
    Last edited: Dec 8, 2022
  2. rosco_y

    rosco_y

    Joined:
    Aug 3, 2016
    Posts:
    31
    This is typical of my code which starts my animations:


    bool success = true;
    foreach (var cube in WIDTH) // WIDTH is a List<SudoCube>
    {
    if (cube.SudoValue < 0) // if is a hole
    success &= cube.UserValueIsValid;

    }
    if (success)
    {
    foreach (var cube in WIDTH)
    {
    cube.SuccessParticles.Play();
    }
    }