title: Changing prefab start color during playtime
body: <p>due to a day/night cycle in my game I need to change the color of a smoke prefab during playtime according the game time but I am having an hard time figuring how to change it several times.</p>
  
  <p>My script works fine to instantiate the prefab with the start color that I want but I am not being able to change it again afterwards.</p>
  
  <p>This is my code:</p>
  
  <pre><code>class Smoke1 : MonoBehaviour
  {
      public GameObject myPrefab;
      public  static GameObject newSmoke;
      public GameObject canvasObject;
  
  void Start()
          {
          GameObject newSmoke = Instantiate(myPrefab, new Vector3(397, -394, 90), Quaternion.Euler(-90, 0, 0)) as GameObject;
          newSmoke.transform.SetParent(canvasObject.transform, false);
          newSmoke.transform.localScale = new Vector3(1, 1, 1);
  
          newSmoke.GetComponent&lt;ParticleSystem&gt;().startColor = Color.red;           
          }
  
      void Update()
          {
          if (TimeManager.gametimeDecimal &lt; 6.0m)       
              newSmoke.GetComponent&lt;ParticleSystem&gt;().startColor = Color.blue;
  
          if (TimeManager.gametimeDecimal &gt;= 6.0m &amp;&amp; TimeManager.gametimeDecimal &lt;= 8.0m)
              newSmoke.GetComponent&lt;ParticleSystem&gt;().startColor = Color.yellow;
  
          if (TimeManager.gametimeDecimal &gt; 8.0m &amp;&amp; TimeManager.gametimeDecimal &lt; 19.0m)
              newSmoke.GetComponent&lt;ParticleSystem&gt;().startColor = Color.green;
          }
  </code></pre>
  
  <p>And this is my hierarchy:<a href="https://i.stack.imgur.com/pZdhE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pZdhE.png" alt="enter image description here"></a> </p>
  
  <p>When I change the start color manually trough the inspector during playtime it works, but I can't figure on how to make my script do it.</p>
  
  <p>Can you give me any advice? </p>
  
  <p>Thanks!</p>