/// <summary>
		/// Starts editor coroutine.
		/// </summary>
		public static EditorCoroutine StartCoroutine (IEnumerator _enumerator)
		{
			EditorCoroutine _editorCoroutine	= null;

#if UNITY_EDITOR
			_editorCoroutine					= new EditorCoroutine(_enumerator);

			// Starts coroutine
			EditorApplication.update			+= _editorCoroutine.Update;
#endif

			return _editorCoroutine;
		}
Ejemplo n.º 2
0
        public void StartRequest()
        {
            if (WWWObject == null || string.IsNullOrEmpty(URL.URLString))
            {
                Debug.LogError("[WebRequest] Sending request is aborted");
                return;
            }

            if (IsAsynchronous)
            {
#if UNITY_EDITOR
                // Coroutine to run in editor mode
                if (!Application.isPlaying)
                {
                    EditorCoroutine.StartCoroutine(StartAsynchronousRequest());
                    return;
                }
#endif
                // Create surrogate object if required
                if (surrogateMonobehaviour == null)
                {
                    GameObject _surrogateGO = new GameObject();

                    // Make it persistent object
                    GameObject.DontDestroyOnLoad(_surrogateGO);

                    // Hide it in hierarchy and add a mono component
                    _surrogateGO.hideFlags = HideFlags.HideInHierarchy;
                    surrogateMonobehaviour = _surrogateGO.AddComponent <MonoBehaviour>();
                }

                // Start coroutine using surrogate object
                surrogateMonobehaviour.StartCoroutine(StartAsynchronousRequest());
            }
            else
            {
                while (!WWWObject.isDone)
                {
                }

                OnFetchingResponse();
            }
        }