• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.WWW类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: LoadPath

        public static bool LoadPath(string filePath)
        {
            if (!string.IsNullOrEmpty(filePath))
            {
                string text = string.Empty;
                try
                {
                    if (filePath.Contains("://"))
                    {
                        WWW www = new WWW(filePath);
                        while (!www.isDone) ;
                        text = www.text;
                    }
                    else
                    {
                        if (File.Exists(filePath))
                        {
                            StreamReader file = File.OpenText(filePath);
                            text = file.ReadToEnd();
                            file.Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.LogErrorFormat("Error Loading File [{0}]", filePath);
                    return false;
                }

                return LoadText(text);
            }

            return false;
        }
开发者ID:AlkaidFang,项目名称:Rosetta,代码行数:34,代码来源:FileReader.cs


示例17: LoadTexture

        public void LoadTexture(String relativePath, ref Texture2D targetTexture)
        {
            var imageLoader = new WWW("file://" + root + relativePath);
            imageLoader.LoadImageIntoTexture(targetTexture);

            if (imageLoader.isDone && imageLoader.size == 0) allTexturesFound = false;
        }
开发者ID:raad287,项目名称:KOS,代码行数:7,代码来源:TermWindow.cs


示例18: Post

        public void Post(string url, Action<JSONObject> success, Action<string> error)
        {
            WWWForm form = new WWWForm();
            WWW www = new WWW(api + url, form);

            StartCoroutine(WaitForRequest(www, success, error));
        }
开发者ID:imclab,项目名称:coinding-api-unity,代码行数:7,代码来源:Transport.cs


示例19: Hoge

 IEnumerator Hoge()
 {
     var www = new WWW("http://google.co.jp/");
     Debug.Log("W");
     yield return www;
     Debug.Log(www.text);
 }
开发者ID:gameserver,项目名称:UniRx,代码行数:7,代码来源:EditorBehaviourTest.cs


示例20: DownloadAsTexture

        IEnumerator DownloadAsTexture(ImageData imageData)
        {
            Debug.Log ("[JplImageLoader] download next image: " + imageData.Url);

            WWW www = new WWW (imageData.Url);

            while (www.progress < 1 && onImageLoadingProgress != null) {
                onImageLoadingProgress (www.progress);
                yield return null;
            }

            yield return www;

            if (www.error == null) {
                imageData.Texture = www.texture;

                if (onImageLoadingComplete != null) {
                    onImageLoadingComplete (imageData);
                }
            } else {
                if (onImageLoadingError != null) {
                    onImageLoadingError (www.error);
                }
            }
        }
开发者ID:cemrich,项目名称:From-Outer-Space,代码行数:25,代码来源:JplImageLoader.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.WWWForm类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.Vector4类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap