title: Workaround to make IEnumerator somehow return value
body: <p>In my Unity game you can place various objects on the surface of the terrain and I need to save the timestamp in a file when new object is placed. I have the saving system working and with some help I was able to get timestamp from the server. It seems you must use IEnumerator in order to get data from server but this created a new problem for me. Since IEnumerator is not a function it can't simply return anything. And since it can't return anything I need a workaround to pass the timestamp from the IEnumerator back to the place it was asked for. How I planned I would be able to get the timestamp:</p>
  
  <pre><code> int _timestamp = ServerTime.Get();
  </code></pre>
  
  <p>So I could easily store it like</p>
  
  <pre><code>gameObject.GetComponent&lt;_DrillStats&gt;().timestamp = _timestamp;
  gameObject.GetComponent&lt;_OtherStats&gt;().timestamp = _timestamp;
  gameObject.GetComponent&lt;_EvenMoreStats&gt;().timestamp = _timestamp;
  </code></pre>
  
  <p>Here is the full code for receiving the timestamp:</p>
  
  <pre><code>using UnityEngine;
  using System;
  using System.Collections;
  
  public class ServerTime : MonoBehaviour
  {
      private static ServerTime localInstance;
      public static ServerTime time { get { return localInstance; } }
  
      private void Awake()
      {
          if (localInstance != null &amp;&amp; localInstance != this)
          {
              Destroy(this.gameObject);
          }
          else
          {
              localInstance = this;
          }
      }
  
      public static void Get()
      {
          if (time == null)
          {
              Debug.Log("Script not attached to anything");
              GameObject obj = new GameObject("TimeHolder");
              localInstance = obj.AddComponent&lt;ServerTime&gt;();
              Debug.Log("Automatically Attached Script to a GameObject");
          }
  
          time.StartCoroutine(time.ServerRequest());
      }
  
      IEnumerator ServerRequest()
      {
          WWW www = new WWW("http://www.businesssecret.com/something/servertime.php");
  
          yield return www;
  
          if (www.error == null) 
          {
              int _timestamp = int.Parse (www.text);
  
              // somehow return _timestamp
              Debug.Log (_timestamp);
          }
          else
          {
              Debug.LogError ("Oops, something went wrong while trying to receive data from the server, exiting with the following ERROR: " + www.error);
          }
  
      }
  
  }
  </code></pre>