Display gameObject after Particle System stop

How to display panel after particle system stop emitting?
I know it has to be under m.MaxParticles=0;

public ParticleSystem firePS;
public Button btnSweep;
public GameObject panel;

    void Start()
    {
        btnSweep = btnSweep.GetComponent<Button>();
        btnSweep.onClick.AddListener(AfterClick);
    }

    public void AfterClick()
    {   
            ParticleSystem.MainModule m = firePS.main;
            m.maxParticles = 0;  
            Debug.Log("done");
            panel.gameObject.SetActive(true);
    }

To use the OnParticleSystemStopped callback, you also have to configure the “Stop Action” in the particle system inspector. Choose Callback. Alternatively, you can do it via script, as per the docs link you were given:

“In order to receive the callback, you must set the ParticleSystem.MainModule.stopAction property to Callback.”

Hi,
try this:

it’s not working, the debug i put does not come out.

public ParticleSystem firePS;
public Button btnSweep;
public GameObject panel;

void Start()
{
    btnSweep = btnSweep.GetComponent<Button>();
    btnSweep.onClick.AddListener(AfterClick);
}

public void AfterClick()
{   
    ParticleSystem.MainModule m = firePS.main;
    m.maxParticles = 0;
    m.stopAction = ParticleSystemStopAction.Callback;        
}

private void OnParticleSystemStopped()
{
    Debug.Log("donefire");
    panel.gameObject.SetActive(true);
}

try firePS.Stop() instead of it.

But is it related ? like the afterClick() went well, but onParticleSystem() does not come out

try this code:

public ParticleSystem firePS;
public Button btnSweep;
public GameObject panel;

void Start()
{
    btnSweep = btnSweep.GetComponent<Button>();
    btnSweep.onClick.AddListener(AfterClick);
}

public void AfterClick()
{
    ParticleSystem.MainModule m = firePS.main;
    m.stopAction = ParticleSystemStopAction.Callback; // set the "stop action" of the particle system to "Callback.", so that desired funtion runs once the particle system stops
    m.maxParticles = 0;
    StartCoroutine(ShowPanelAfterParticlesStop());
}

private IEnumerator ShowPanelAfterParticlesStop()
{
    while (firePS.isPlaying) // return nothing until the particle system stops playing
    {
        yield return null;
    }

    panel.SetActive(true); // show and display the panel after particles stop emitting
    Debug.Log("done");
}