title: Accessing Unity particle emitter via script
body: <p>I have a particle system created, and in a certain point in my game I would like to increase the max particles.</p>
  
  <p>As a result, I created a game object and attached a box 2d collider to it that fires when it comes in contact with the player. In that script, I have created a public GameObject leafParticleSystem, and dragged the particle system into it. </p>
  
  <p>However, in my code, I am unable to do anything like </p>
  
  <pre><code>leafParticleSystem.maxParticles=500; 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>leafParticleSystem.emission.rate=5.0f
  </code></pre>
  
  <p>My code is also saying </p>
  
  <pre><code>"MissingComponentException: There is no 'ParticleSystem' attached to the "Herld" game object, but a script is trying to access it.
  You probably need to add a ParticleSystem to the game object "Herld". Or your script needs to check if the component is attached before using it.untime/Export/Coroutines.cs:17)"
  </code></pre>
  
  <p>However, this "Herld" GameObject is not the particle system (nor do I want to add one to it) It however, does have the script attached which I am dragging the particle system (leaf particle system) to. I am just trying to modify the leaf particle system from my code in the "Herld" object. </p>
  
  <p>Would appreciate if I could get any assistance </p>
  
  <p>Script Attached</p>
  
  <pre><code>using UnityEngine;
  using UnityEngine.UI;
  using System.Collections;
  
  public class WindEffect : MonoBehaviour {
  //  Rigidbody2D _rigidbody;
      // Use this for initialization
  
      //Storm Warning
      public GameObject AOE;
      public GameObject UIStormInterface;
      public GameObject UIWindZone;
  
      public GameObject LeafStormParticleSystem;
  
  
      public float ActivateFor=5.0f;
      public float stormLength=5.0f; 
  
  
      void Start () {
  
      }
  
      // Update is called once per frame
      void Update () {
  
      }
      void Awake () {
  
  //      _rigidbody = GetComponent&lt;Rigidbody2D&gt; ();
      }
  
      void OnTriggerEnter2D(Collider2D col)
      {
      // Debug.Log("Object touched trigger");
      //  Debug.Log (col.transform.name); 
          if (col.gameObject.name == "Player") {
              Debug.Log ("Collided with Storm Herald");
              StartCoroutine (TemporarilyActivateStormWarning (ActivateFor));
  
          }
      }
  
      private IEnumerator TemporarilyActivateStormWarning(float ActivateFor) {
      //Show Storm Warning
          this.gameObject.GetComponent&lt;BoxCollider2D&gt;().enabled=(false);
          UIStormInterface.GetComponent&lt;Text&gt;().text="A Violent Storm is Approaching";
          UIStormInterface.SetActive(true);
  
          UIWindZone.SetActive (true);
          //Wait for 5 seconds then activate storm for 5 seconds
          yield return new WaitForSeconds(ActivateFor);
  
          UIStormInterface.SetActive(false);
          AOE.SetActive (true);
  
          //  ParticleSystem LeafStormParticleSystem = GetComponent&lt;ParticleSystem&gt;();
      //  LeafStormParticleSystem.emission.rate = 5.0f;
          LeafStormParticleSystem.maxParticles = 500;
  
  
          yield return new WaitForSeconds(stormLength);
  
  
          //Turn off Storm
          AOE.SetActive (false);
          //Tell user storm is stopped for 2 seconds.
  
          UIStormInterface.GetComponent&lt;Text&gt;().text="Storm has Passed";
          UIStormInterface.SetActive(true);
          yield return new WaitForSeconds(3);
          UIStormInterface.SetActive(false);
          UIWindZone.SetActive (false);
      }
      void OnTriggerStay2D(Collider2D col)
      {
          if (col.gameObject.name == "WindObject") {
              Debug.Log ("Collided");
              //  Debug.Log (col.transform.name); 
          //  Wind();
              //StartCoroutine(WindStart());
          }
      }
      /*
      IEnumerator WindStart(){
          Debug.LogError ("Slow Time.");
  
          //SlowTheTime();
      //  yield return new WaitForSeconds(3.5f);
          //  Debug.LogError ("Slow Time.");
      //  Wind ();
      }*/
  
  
      void OnCollisionEnter2D(Collision2D col)
      {
  //      Debug.Log (col.transform.name); 
      }
      void OnTriggerStay(Collider col)
      {
          Debug.Log("Object is in trigger");
  
      }
      void OnTriggerExit(Collider other)
      {
          Debug.Log("Object left the trigger");
      }
  
  
      /*
      void Wind(){
          _rigidbody = GetComponent&lt;Rigidbody2D&gt; ();
          Debug.Log ("test got here");
          Debug.Log (this.gameObject.name);
          this._rigidbody.AddForce (-Vector2.left * 100 );
      }*/
  
  }
  </code></pre>