当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.WWW类代码示例

本文整理汇总了C#中UnityEngine.WWW的典型用法代码示例。如果您正苦于以下问题:C# WWW类的具体用法?C# WWW怎么用?C# WWW使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WWW类属于UnityEngine命名空间,在下文中一共展示了WWW类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartLoadingData

		public static void StartLoadingData ()
		{
			string BASE_DATA_PATH = "https://jetsons.firebaseio.com/gamedata/";
			string PRETTY_COMMAND = "?print=pretty";

			string url = BASE_DATA_PATH + "weapons.json" + PRETTY_COMMAND;

			Debug.Log("downloading from: " + url);
			WWW www = new WWW (url);

			while(!www.isDone);

			Debug.Log("downloading complete: " + url);

			if (www.error != null) {
				Debug.LogError ("can't load remote data: " + www.error);
				return;
			}

			Debug.Log("parsing config");

			string json = www.text;
			var configList = DataUtils.CreateDataListFromJson<WeaponData> (json);
			if (configList != null) {
				Debug.Log("saving to file");
				FileUtils.SaveFileToStreamingAssets("weapons.json", json);
				Debug.Log("saving complete!");
			}		
		}
开发者ID:Kundara,项目名称:project1,代码行数:29,代码来源:JetsonsEditorUtils.cs

示例2: GenerateLoadProcess

        protected override IEnumerator GenerateLoadProcess()
        {
            string target = GetPlatformFolderForAssetBundles ();
            string baseUrl = Path.Combine (ResourceManager.Instance.assetBundleDomain, target);

            string manifestUrl = Path.Combine (baseUrl, target);
            using (WWW www = new WWW (manifestUrl))
            {
                while (www.progress < 1.0f || www.isDone == false)
                {
                    progress = www.progress;
                    yield return null;
                }
                if (www.assetBundle == null)
                {
                    Failed (www.error);
                    yield break;
                }

                AssetBundleRequest async = www.assetBundle.LoadAssetAsync ("AssetBundleManifest");
                while (async.progress < 0.9f || async.isDone == false)
                {
                    yield return null;
                }
                if (async.asset == null)
                {
                    Failed ("AssetBundle.LoadAssetAsync");
                    yield break;
                }

                assetBundleManifest = async.asset as AssetBundleManifest;
                Successed ();
            }
        }
开发者ID:hiyorin,项目名称:UnityFramework,代码行数:34,代码来源:AssetBundleManifestLoader.cs

示例3: getAdPlan

	private IEnumerator getAdPlan(string url, System.Action<WWW> callback) {
		WWW www = new WWW(url);
			
		yield return www;
			
		callback(www);
	}
开发者ID:mengtest,项目名称:Cirim,代码行数:7,代码来源:UnityAdsEditor.cs

示例4: CheckForUpdate

        public static Boolean CheckForUpdate(bool ForceCheck, bool versionSpecific)
        {
            string updateSite = versionSpecific ? "http://magico13.net/KCT/latest-0-24-0" : "http://magico13.net/KCT/latest";
            //System.Version current = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            //CurrentVersion = current.ToString();
            if (ForceCheck || WebVersion == "")
            {
                Debug.Log("[KCT] Checking for updates...");
                WWW www = new WWW(updateSite);
                while (!www.isDone) { }

                WebVersion = www.text.Trim();
                //Debug.Log("[KCT] Current version: " + CurrentVersion);
                Debug.Log("[KCT] Received version: " + WebVersion);

                if (WebVersion == "")
                    UpdateFound = false;
                else
                {
                    System.Version webV = new System.Version(WebVersion);
                    UpdateFound = (new System.Version(CurrentVersion).CompareTo(webV) < 0);//CompareVersions(WebVersion, CurrentVersion);
                }
            }
            if (UpdateFound)
                Debug.Log("[KCT] Update found: "+WebVersion+" Current: "+CurrentVersion);
            else
                Debug.Log("[KCT] No new updates. Current: " + CurrentVersion);
            return UpdateFound;
        }
开发者ID:ntwest,项目名称:KCT,代码行数:29,代码来源:KCT_UpdateChecker.cs

示例5: GetNewTrades

        IEnumerator GetNewTrades()
        {
            WWWForm form = new WWWForm();
            form.AddField("_Token", APIKey); //The token
            form.AddField("Symbols", symbols); //The Symbols you want
            DateTimeOffset currentTimeEST = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, easternZone);

            
            form.AddField("StartDateTime", lastUpdatedEST.ToString(timeFormat)); //The proper DateTime in the proper format
            form.AddField("EndDateTime", currentTimeEST.AddTicks(-1000000).ToString(timeFormat)); //The proper DateTime in the proper format
            var url = "http://ws.nasdaqdod.com/v1/NASDAQTrades.asmx/GetTrades HTTP/1.1";

            WWW www = new WWW(url, form);
            yield return www;
            if (www.error == null)
            {
                //Sucessfully loaded the JSON string
                Debug.Log("Loaded following JSON string" + www.text);

            }
            else
            {
                Debug.Log("ERROR: " + www.error);
            }
        }
开发者ID:chen-ye,项目名称:SoundStockUnity,代码行数:25,代码来源:StockManager.cs

示例6: BeginLoad

        public void BeginLoad(CRequest req)
        {
            this.isFree = false;
            this._req = req;
            this.enabled = true;
            string url = req.url;
            if (url.IndexOf("://") == -1)
            {
                url = "file://" + url;
            }
            if (req.head is WWWForm)
            {
                www = new WWW(url, (WWWForm)req.head);
            }
            else if (req.head is byte[])
            {
                www = new WWW(url, (byte[])req.head);
            }
            else
            {
                //			if (url.StartsWith ("http")) {
                //				if(CResLoader.assetBundleManifest!=null)
                //					www = WWW.LoadFromCacheOrDownload (url, CResLoader.assetBundleManifest.GetAssetBundleHash (req.assetBundleName), 0);
                //				else
                //					www = WWW.LoadFromCacheOrDownload (url, 0);
                //			}
                //            else
                www = new WWW(url);
            }

            //Debug.LogFormat("<color=green> begin load {0} </color>", url);
        }
开发者ID:ChaseDream2015,项目名称:hugula,代码行数:32,代码来源:CCar.cs

示例7: Download

        public static void Download()
        {
            string url = PythonManager.GetPythonDownloadUrl ();

            www = new WWW (url);
            EditorApplication.update = WhileDownloading;
        }
开发者ID:josec89,项目名称:wakatime-unity,代码行数:7,代码来源:PythonInstaller.cs

示例8: LoadAssetBundle

 public IEnumerator LoadAssetBundle()
 {
     state = DownloadState.Init;
     downLoader = new WWW(path + fileName);
     state = DownloadState.Loading;
     yield return downLoader;
     if(downLoader.error!=null)
     {
         state = DownloadState.LoadFailed;
         downLoader.Dispose();
         yield break;
     }
     else
     {
         size = downLoader.bytesDownloaded;
         assetBundle = downLoader.assetBundle;
         if(assetBundle==null)
         {
             state = DownloadState.LoadFailed;
         }
         else
         {
             state = DownloadState.Loaded;
         }
         downLoader.Dispose();
     }
 }
开发者ID:monitor1394,项目名称:UnityGameClient,代码行数:27,代码来源:AssetBundleLoader.cs

示例9: Request

        private IEnumerator Request(SHKeyValue keyValue, string methodName, Action<string> valueReceived = null)
        {
            var url = string.Format (CultureInfo.InvariantCulture,
                "{0}/services/storage/{1}.ashx?playerId={2}&key={3}&value={4}",
                m_serverAddress, methodName, m_playerId, keyValue.Key, keyValue.Value);

            SHLog.Debug ("SHGlobalServerKeyValueStorageProvider: requesting url '{0}'.", url);

            var www = new WWW (url);
            yield return www;

            if (String.IsNullOrEmpty (www.error))
            {
                var response = www.text;

                if (!String.IsNullOrEmpty (response))
                {
                    SHLog.Debug ("SHGlobalServerKeyValueStorageProvider: response received '{0}'.", response);

                    if (valueReceived != null)
                    {
                        valueReceived (response.Replace("\"", ""));
                    }
                }
            }
            else
            {
                SettingValueFailed.Raise (this, new SHSettingValueFailedEventArgs (keyValue));
            }
        }
开发者ID:skahal,项目名称:Skahal-Unity-Scripts,代码行数:30,代码来源:SHGlobalServerKeyValueStorageProvider.cs

示例10: PostJSON

	IEnumerator PostJSON(string url){

		string jsonString = "{\"itemName\":\"Spear\",\"itemType\":\"aa\",\"price\":30000,\"attack\":100,\"defense\":0,\"description\":\"10000\"}";

		// HEADERはHashtableで記述
		Hashtable header = new Hashtable ();
		header.Add ("Content-Type", "text/json");
		header.Add("Content-Length", jsonString.Length);

		var encording = new System.Text.UTF8Encoding ();

		print("jsonString: " + jsonString);

		// 送信開始
		var request = new WWW (url, encording.GetBytes(jsonString), header);
		yield return request;


		// 成功
		if (request.error == null) {
			Debug.Log("WWW Ok!: " + request.data);
		}
		// 失敗
		else{
			Debug.Log("WWW Error: "+ request.error);          
		}

	}
开发者ID:trananh1992,项目名称:3DActionGame,代码行数:28,代码来源:JSONSampleWeb.cs

示例11: CheckForUpdate

        public static Boolean CheckForUpdate(bool ForceCheck, bool versionSpecific)
        {
            #if DEBUG
            string updateSite = "http://magico13.net/KCT/latest_beta";
            #else
            string updateSite = versionSpecific ? "http://magico13.net/KCT/latest-1-0-0" : "http://magico13.net/KCT/latest";
            #endif
            if (ForceCheck || WebVersion == "")
            {
                Debug.Log("[KCT] Checking for updates...");
                WWW www = new WWW(updateSite);
                while (!www.isDone) { }

                WebVersion = www.text.Trim();
                Debug.Log("[KCT] Received version: " + WebVersion);

                if (WebVersion == "")
                    UpdateFound = false;
                else
                {
                    System.Version webV = new System.Version(WebVersion);
                    UpdateFound = (new System.Version(CurrentVersion).CompareTo(webV) < 0);
                }
            }
            if (UpdateFound)
                Debug.Log("[KCT] Update found: "+WebVersion+" Current: "+CurrentVersion);
            else
                Debug.Log("[KCT] No new updates. Current: " + CurrentVersion);
            return UpdateFound;
        }
开发者ID:fingerboxes,项目名称:KCT,代码行数:30,代码来源:KCT_UpdateChecker.cs

示例12: SendPostRequest

        static public IEnumerator SendPostRequest(string url, byte[] data, Dictionary<string, string> headers, System.Action<WWW> callback, System.Action<string> errorCallback)
        {
            System.Collections.Generic.Dictionary<string, string> defaultHeaders = new System.Collections.Generic.Dictionary<string, string>(); ;
            if (data != null)
            {
                defaultHeaders.Add("Content-Type", "application/octet-stream");
                defaultHeaders.Add("Content-Length", data.Length.ToString());
            }

            if (headers != null)
            {
                foreach(KeyValuePair<string, string> pair in headers)
                {
                    defaultHeaders.Add(pair.Key, pair.Value);
                }                
            }

            WWW www = new WWW(url, data, defaultHeaders);
            yield return www;

            if (!System.String.IsNullOrEmpty(www.error))
            {
                if (errorCallback != null)
                {
                    errorCallback(www.error);
                }
            }
            else
            {
                callback(www);
            }
        }
开发者ID:yakolla,项目名称:HelloVertX,代码行数:32,代码来源:Http.cs

示例13: CreateTile

        public IEnumerator CreateTile(World w, Vector2 realPos, Vector2 worldCenter, int zoom)
        {
            var tilename = realPos.x + "_" + realPos.y;
            var tileurl = realPos.x + "/" + realPos.y;
            var url = "http://vector.mapzen.com/osm/water,earth,buildings,roads,landuse/" + zoom + "/";

            JSONObject mapData;
            if (File.Exists(tilename) || offline)
            {
                var r = new StreamReader(tilename, Encoding.Default);
                mapData = new JSONObject(r.ReadToEnd());
            }
            else
            {
                var www = new WWW(url + tileurl + ".json");
                yield return www;

                var sr = File.CreateText(tilename);
                sr.Write(www.text);
                sr.Close();

                mapData = new JSONObject(www.text);
            }
            Rect = GM.TileBounds(realPos, zoom);

            CreateBuildings(mapData["buildings"]);
            CreateRoads(mapData["roads"]);
        }
开发者ID:QuantumLeap,项目名称:Vi3W,代码行数:28,代码来源:Tile.cs

示例14: PostComment

        public IEnumerator PostComment(UserComment comment, Action<bool> resultAction)
        {
            var jsonString = JsonConvert.SerializeObject(comment);

            var headers = new Dictionary<string, string>();
            headers.Add("Content-Type", "text/json");

            var encoding = new UTF8Encoding();
            var request = new WWW(CommentUrl, encoding.GetBytes(jsonString), headers);

            yield return request;

            if (request.error != null)
            {
                Debug.Log("Error:" + request.error);
                resultAction(false);
            }
            else
            {
                Debug.Log("Request Successful");
                Debug.Log(request.text);
                resultAction(true);
            }

        }
开发者ID:harjup,项目名称:WizardBroadcast,代码行数:25,代码来源:CommentRepository.cs

示例15: FetchBytes

        static IEnumerator FetchBytes(WWW www, IObserver<byte[]> observer, IProgress<float> reportProgress, CancellationToken cancel)
        {
            using (www)
            {
                while (!www.isDone && !cancel.IsCancellationRequested)
                {
                    if (reportProgress != null)
                    {
                        try
                        {
                            reportProgress.Report(www.progress);
                        }
                        catch (Exception ex)
                        {
                            observer.OnError(ex);
                            yield break;
                        }
                    }
                    yield return null;
                }

                if (cancel.IsCancellationRequested) yield break;

                if (!string.IsNullOrEmpty(www.error))
                {
                    observer.OnError(new Exception(www.error));
                }
                else
                {
                    observer.OnNext(www.bytes);
                    observer.OnCompleted();
                }
            }
        }
开发者ID:hoghweed,项目名称:LightNode,代码行数:34,代码来源:ObservableWWW.cs


注:本文中的UnityEngine.WWW类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。