Пример #1
0
        /// <summary>
        /// Downloads text from a URL without caching it in Unity (browser will still cache normally)
        /// </summary>
        private IEnumerator <IYieldInstruction> DownloadText(string url, Action <string> wwwDataResult)
        {
            SpooledWWW assetWWW = new SpooledWWW(url);

            yield return(new YieldForSpooledWWW(assetWWW));

            if (!String.IsNullOrEmpty(assetWWW.result.error))
            {
                Console.LogError("Error while trying to download text: " + assetWWW.result.error + " From path: " + url);
            }
            wwwDataResult(assetWWW.result.data);
        }
Пример #2
0
        /// <summary>
        /// Downloads text from a URL without caching it in Unity (browser will still cache normally)
        /// </summary>
        private IEnumerator <IYieldInstruction> GetServiceResult(string url, Action <XmlDocument> wwwDataResult)
        {
            SpooledWWW assetWWW = new SpooledWWW(url);

            yield return(new YieldForSpooledWWW(assetWWW));

            if (!String.IsNullOrEmpty(assetWWW.result.error))
            {
                Console.WriteLine("Error while trying to download text: " + assetWWW.result.error + " From path: " + url);
            }
            XmlDocument wwwDoc = new XmlDocument();

            wwwDoc.LoadXml(assetWWW.result.data);
            GameFacade.Instance.RetrieveMediator <LoggerMediator>().Logger.Log("GetServiceResult xml = " + wwwDoc.OuterXml, LogLevel.Info);

            wwwDataResult(wwwDoc);
        }
Пример #3
0
        //The coroutine to download asset using WWW class and convert to a Unity Object.
        private IEnumerator <IYieldInstruction> DownloadLateBoundAsset(string path, Action <UnityEngine.Object> loadedAssetCallback)
        {
            SpooledWWW assetWWW = new SpooledWWW(path);

            yield return(new YieldForSpooledWWW(assetWWW));

            if (!String.IsNullOrEmpty(assetWWW.result.error))
            {
                throw new Exception("Error while trying to download late bound asset: " + assetWWW.result.error);
            }

            UnityEngine.Object returnObject = assetWWW.result.assetBundle.mainAsset;

            if (returnObject == null)
            {
                throw new Exception("The WWW class could not load a UnityEngine.Object from path " + path);
            }

            DownloadFinishedExecuteCallbacks(path, loadedAssetCallback, returnObject);
        }
Пример #4
0
        //The coroutine to download asset using WWW class and convert to Texture asset.
        private IEnumerator <IYieldInstruction> DownloadTextureAsset(string path, Action <UnityEngine.Object> loadedAssetCallback)
        {
            SpooledWWW assetWWW = new SpooledWWW(path);

            yield return(new YieldForSpooledWWW(assetWWW));

            UnityEngine.Object returnObject = null;

            if (String.IsNullOrEmpty(assetWWW.result.error))
            {
                returnObject = assetWWW.result.texture;
            }

            if (returnObject == null)
            {
                Console.LogError("The WWW class could not load a UnityEngine.Object from path (" + path + "): " + assetWWW.result.error);
                returnObject = Resources.Load("GUI/BrokenLink");
            }

            DownloadFinishedExecuteCallbacks(path, loadedAssetCallback, returnObject);
        }
Пример #5
0
 public YieldForSpooledWWW(SpooledWWW www)
 {
     mWWW = www;
 }