Is there a way to get a particle system to play WITHOUT calling .Play() from script?

I have some particle systems parented to a rigged character, with several animations on the character. At certain points during the animation, I want to play one of the particle systems, then have it stop, and play again later in the animation.

The situation is - I cannot animate ParticleSystem.enableEmission on that object (for an unrelated reason), so I have made a script that accepts a public ParticleSystem, and when the GameObject holding the script is enabled, it calls ParticleSystem.Play(). Like so:

using UnityEngine;
using System.Collections;

public class ParticleAniCtrl : MonoBehaviour {
	public ParticleSystem particle;
	
	void OnEnable() {
		if(particle) {
			if (!particle.isPlaying) {
				particle.Play();
			}
		}
	}
	
	void OnDisable() {
		if(particle) {
			if (particle.isPlaying) {
				particle.Stop();
			}
		}
	}
}

(Play on awake is unchecked on the systems I’m using.)

This actually works fine. But this project is going to be sent off to another studio and I am concerned that they are going to ask me to do these animations without adding any new script that isn’t in their system already.

I thought of leaving PlayOnAwake checked in the particle system, and simply animating whether the particle system is enabled. The problem is, this doesn’t always work if it’s not the first playthough for the system - because it doesn’t necessarily go back to the beginning when it’s disabled and reenabled.

Actually just having .Play() get triggered has exactly the desired effect, I just want to do this without having to use a new script. Is there a way to trigger the particle system to play from the animation timeline?

I’ve added particle system to a child gameObject, marked PlayOnAwake to true and in the animator I’m toggling gameObject.IsActive on and off.

Not a universal solution but works for me

A late response, but for anyone who views this in the future, the way I did it was simply set the emission rate to 0, and it’s kind of an annoying script, but this is how I enable it,
if (raining) StartRain();
else StopRain();

 public void StartRain()
    {
        ParticleSystem.EmissionModule rn = particles[0].emission;
        rn.rateOverTime = rainRate;
    }

    public void StopRain()
    {
        ParticleSystem.EmissionModule rn = particles[0].emission;
        rn.rateOverTime = 0;
    }

I have an array of particle systems, and the “rainRate” is a serialized float that I set in the inspector.

Add event on a keyframe in Animation and call your method to Play a ParticleSystem.

It’s true that you have to write a method that calls method ParticleSystem.Play() in a Script but, you decide in the Animation when it will be executed.

Obviously, set ParticleSystem PlayOnAwake = false and Loop = false.

I think an alternative way would be, but I may be wrong.

ParticleSystem.enable(true);