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


C# WWW类代码示例

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


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

示例1: OnCollisionEnter

    void OnCollisionEnter( Collision coll )
    {
        Letras2 letrasScript = Camera.main.GetComponent<Letras2>();

        // GameObject cambiacolorGO = GameObject.Find("Cambiacolor");
        // cambiacolorGT = cambiacolorGO.GetComponent<GUIText>();

        GameObject collidedWith = coll.gameObject;

        //cuando letra falsa choca con el pulpo, llama la funcion de matar todas las letras en la class ApplePicker2(limpiar todas las letras y elimina un corazon)
        if ( collidedWith.tag == "Incorrecto"){

            ApplePicker2 apScript = Camera.main.GetComponent<ApplePicker2>();
            // Call the public AppleDestroyed() method of apScript
            apScript.IncorrectoDestroyed();

        }

        //*cuando letra correcta choca con el pulpo, seguimos pensando...
        else if (collidedWith.tag == "Yes") {
            Destroy (collidedWith);
            letrasScript.success = true;

            string url = "http://localhost:8888/[email protected]&&nameactor=alexiunity";
            // Asignamos la url del Servidor servernodejs y las variables que se enviaran a traves del metodo GET al Servidor xAPI
            WWW www = new WWW(url);
            StartCoroutine(WaitForRequest(www));

            Application.LoadLevel ("_Escenariofinal"); // al cumplir la condicion de aprobación se lee el escenario final
            // de esta forma hacemos el llamado de la funcion XAPI y envio de datos que se cargaran dentro del Badge
        }
    }
开发者ID:freddycoa,项目名称:xapiopenbadges,代码行数:32,代码来源:gameXAPI.cs

示例2: CompareAndroidVersion

 private IEnumerator CompareAndroidVersion()
 {
     ReadPersistentVersion();
     string path = Application.streamingAssetsPath + "/" + VERSION_FILE_NAME;
     WWW www = new WWW(path);
     yield return www;
     this.streamingVersion = int.Parse(www.text.Trim());
     Debug.Log(string.Format(" persistentVersion= {0},streamingVersion = {1}", this.persistentVersion, this.streamingVersion));
     if (this.persistentVersion < this.streamingVersion)// copy streaming to persistent
     {
         string fileName = Application.streamingAssetsPath + "/data.zip";//  --System.IO.Path.ChangeExtension(Application.streamingAssetsPath,".zip");
         CRequest req = new CRequest(fileName);
         req.OnComplete += delegate(CRequest r)
         {
             byte[] bytes = null;
             if (r.data is WWW)
             {
                 WWW www1 = r.data as WWW;
                 bytes = www1.bytes;
             }
             FileHelper.UnZipFile(bytes, Application.persistentDataPath);
             LuaBegin();
         };
         this.multipleLoader.LoadReq(req);
     }
     else
     {
         LuaBegin();
     }
 }
开发者ID:QinFangbi,项目名称:hugula,代码行数:30,代码来源:Begin.cs

示例3: GetJSONData

    IEnumerator GetJSONData()
    {
        WWW www = new WWW("http://stag-dcsan.dotcloud.com/shop/items/powerup");

        float elapsedTime = 0.0f;

        while (!www.isDone) {

          elapsedTime += Time.deltaTime;

          if (elapsedTime >= 20.0f) break;

          yield return null;

        }

        if (!www.isDone || !string.IsNullOrEmpty(www.error)) {

          Debug.LogError(string.Format("Fail Whale!\n{0}", www.error));

          yield break;

        }

        string response = www.text;

        Debug.Log(elapsedTime + " : " + response);

           _data = (IList) Json.Deserialize(response);
        IDictionary item = (IDictionary) _data[_dataIndex];

        LoadData ();
        //UILabel DetailLabel = GameObject.Find("DetailLabel").GetComponent<UILabel>();
        //DetailLabel.text = item["description"].ToString();
    }
开发者ID:jmsalandanan,项目名称:DevAssessment,代码行数:35,代码来源:JSONParser.cs

示例4: Login

    IEnumerator Login()
    {
        WWWForm form = new WWWForm(); //here you create a new form connection
        form.AddField( "myform_hash", hash ); //add your hash code to the field myform_hash, check that this variable name is the same as in PHP file
        form.AddField( "myform_nick", formNick );
        form.AddField( "myform_pass", formPassword );
        WWW w = new WWW(URL, form); //here we create a var called 'w' and we sync with our URL and the form
        yield return w; //we wait for the form to check the PHP file, so our game dont just hang

        if (w.error != null)
        {
        print(w.error); //if there is an error, tell us
        }

        else
        {
        EXPBar.nick = formNick;
        print("Test ok");
        formText = w.text; //here we return the data our PHP told us

        w.Dispose(); //clear our form in game
        }

        formNick = ""; //just clean our variables
        formPassword = "";
    }
开发者ID:mattmcginty89,项目名称:Dissertation,代码行数:26,代码来源:phpUnity.cs

示例5: AddScore

 /// <summary>
 /// Adds Score to database
 /// </summary>
 /// <param name="name"></param>
 /// <param name="id"></param>
 /// <param name="score"></param>
 /// <returns></returns>
 private IEnumerator AddScore(string name, string id, string score)
 {
     WWWForm f = new WWWForm();
     f.AddField("ScoreID", id);
     f.AddField("Name", name);
     f.AddField("Point", score);
     WWW w = new WWW("demo/theappguruz/score/add", f);
     yield return w;
     if (w.error == null)
     {
         JSONObject jsonObject = new JSONObject(w.text);
         string data = jsonObject.GetField("Status").str;
         if (data != null && data.Equals("Success"))
         {
             Debug.Log("Successfull");
         }
         else
         {
             Debug.Log("Fatel Error");
         }
     }
     else
     {
         Debug.Log("No Internet Or Other Network Issue" + w.error);
     }
 }
开发者ID:power7714,项目名称:centralized-leader-board-unity-used-personal-web-api,代码行数:33,代码来源:Test.cs

示例6: OnImageDownloaded

	private void OnImageDownloaded(WWW www)
	{
		if (www.texture != null && previewTexture != null)
		{
			previewTexture.mainTexture = www.texture;
		}
	}
开发者ID:azanium,项目名称:Klumbi-Unity,代码行数:7,代码来源:CommentsController.cs

示例7: LoadLevelBundle

    public IEnumerator LoadLevelBundle(string levelName, string url, int version)
    {
        //		WWW download;
        //		download = WWW.LoadFromCacheOrDownload( url, version );

        WWW download;
        if ( Caching.enabled ) {
            while (!Caching.ready)
                yield return null;
            download = WWW.LoadFromCacheOrDownload( url, version );
        }
        else {
            download = new WWW (url);
        }

        //		WWW download = new WWW(url);
        //
        yield return download;
        if ( download.error != null ) {
            Debug.LogError( download.error );
            download.Dispose();
            yield break;
        }

        AssetBundle assetBundle = download.assetBundle;
        download.Dispose();
        download = null;

        if (assetBundle.LoadAllAssets() != null)
            Application.LoadLevel(levelName);

        assetBundle.Unload(false);
    }
开发者ID:Matjioe,项目名称:AssetBundlesTests,代码行数:33,代码来源:AssetBundleLoader.cs

示例8: SetScore

    IEnumerator SetScore(int score, string name, string url)
    {
        WWWForm form = new WWWForm();
        form.AddField("Name", name);
        form.AddField("Record", score);
        WWW w = new WWW(url, form);
        yield return w;

        if (!string.IsNullOrEmpty(w.error))
        {
            print(w.error);
        }
        else {
            switch (w.text)
            {
                case "1":
                    print("Sucesso");
                    break;
                case "-1":

                    print( "Erro ao cadastrar.");

                    break;

                default:
                    print(w.text);
                    break;
            }
        }
    }
开发者ID:Lucasmiiller01,项目名称:DefensordoFeudo,代码行数:30,代码来源:ScoreManaher.cs

示例9: CheckForUpdates

    //-------------------------FOR PATCHING -----------------------------------------------------
    IEnumerator CheckForUpdates()
    {    //for the patcher. Check the version first. 
        buildVersion = "1.0";
        updating = true;
        showUpdateButton = false;
        updateMsg = "\n\n\nChecking For Updates..."; //GUI update for user
        yield return new WaitForSeconds(1.0f);                        //make it visible
        updateMsg = "\n\n\nEstablishing Connection...";//GUI update for user
        WWW patchwww = new WWW(url); //create new web connection to the build number site
        yield return patchwww;     // wait for download to finish
        var updateVersion = (patchwww.text).Trim();
        Debug.Log(updateVersion);

        if (updateVersion == buildVersion) //check version
        {    
            updateMsg = "\nCurrently update to date.";
            yield return new WaitForSeconds(1.0f);
            updating = false;
            showGUI = true;
            Debug.Log("No Update Avalible");
            GetComponent<MainMenu>().enabled = true;
        }
        else
        {
            patch = patchwww.text;
            updateMsg = "Update Available.\n\n Current Version: " + buildVersion + "\n Patch Version: " + patchwww.text + "\n\n Would you like to download updates?\n\nThis will close this program and \n will launch the patching program.";
            showUpdateButton = true;
            Debug.Log("Update Avalible");
        }
    }
开发者ID:PrawnStudios,项目名称:Fantasy-RTS,代码行数:31,代码来源:Patcher.cs

示例10: Initialize

    /**
     * Requires that sensorURL has been set
     * Initializes the sensor display module
     * Starts the value updating function (coroutine);
     */
    public IEnumerator Initialize(string URL)
    {
        // Parse URL
        WWW www = new WWW (URL);
        yield return www;
        url = URL;
        JSONClass node = (JSONClass)JSON.Parse (www.text);

        www = new WWW (node["property"]);
        yield return www;
        JSONNode propertyNode = JSON.Parse (www.text);

        resourceProperty = propertyNode ["name"];
        resourceType = myResource.resourceType;
        sensorType = mySensor.sensorType;
        urlDataPoint = url + "value/";

        // Set Base values (name, icon, refreshTime)
        SetIcon ();
        SetName ();

        // Starts UpdateSensorValue coroutine
        StartCoroutine ("UpdateSensorValue");

        yield return null;
    }
开发者ID:OpenAgInitiative,项目名称:gro-ui,代码行数:31,代码来源:SensorDisplayModule.cs

示例11: SavePosi

    public void SavePosi()
    {
        {
            //when the button is clicked        
            //setup url to the ASP.NET webpage that is going to be called
            string customUrl = url + "SameGame/Create";

            //setup a form
            WWWForm form = new WWWForm();

            //Setup the paramaters

            //Save the perks position
            string x = transform.position.x.ToString("0.00");
            string y = transform.position.y.ToString("0.00");
            string z = transform.position.z.ToString("0.00");

            string rx = transform.rotation.x.ToString("0.00");
            string ry = transform.rotation.y.ToString("0.00");
            string rz = transform.rotation.z.ToString("0.00");

            form.AddField("PerksName", transform.name);
            form.AddField("PerkPosition", x + "," + y + "," + z);
            form.AddField("PerkRotation", rx + "," + ry + "," + rz);
            form.AddField("Username", username + "");



            //Call the server
            WWW www = new WWW(customUrl, form);
            StartCoroutine(WaitForRequest(www));
        }
    }
开发者ID:SoulfulSolutions,项目名称:The_Last_Ranger,代码行数:33,代码来源:SavePerksPos.cs

示例12: WebService

	IEnumerator WebService(string URL)
	{
		this.state = State.WaitingForResponse;

		WWW www = new WWW(URL);
		yield return www;

		if (www.error != "" && www.error != null)
		{
			this.state = State.ERROR;
		}
		else {
			string s = www.text;
			if (s.Contains("|"))
			{
				string[] values = s.Split(new char[] {'|'});
				if (values[0] == "ERROR")
				{
					this.state = State.ERROR;
					this.error = values[1];
				} 
				else if (values[0] == "OK")
				{
					this.state = State.OK;
					if (values.Length > 1) this.value = values[1];
				}
			}
		}
	}
开发者ID:CRRDerek,项目名称:Unity-First-Person-Shooter,代码行数:29,代码来源:dreamloPromoCode.cs

示例13: Get

    IEnumerator Get(string url, int kindinfo)
    {
        WWW www = new WWW (url);
        yield return www;

        var jsonData = Json.Deserialize(www.text) as Dictionary<string,object>;

        switch (kindinfo) {
        case 1:
            state_parse(jsonData);
            break;
        case 2:
            users_parse(jsonData);
            break;
        case 3:
            play_parse(jsonData);
            break;
        case 4:
            winner_parse(jsonData);
            break;
        case 5:
            piece_parse(jsonData);
            break;
        default:
            break;
        }
    }
开发者ID:HidetoSai,项目名称:Syogi,代码行数:27,代码来源:Getinfo.cs

示例14: RequestWWW

    private IEnumerator RequestWWW(string url, byte[] data, Dictionary<string, string> headers, 
		Action<CNetResponse> complete, Action<string> error)
    {
        var www = new WWW(url, data, headers);
        var responseTime = 10f;
        while (www.isDone && responseTime > 0f)
        {
            responseTime -= Time.deltaTime;
            yield return m_Waiting;
        }
        if (responseTime < 0f)
        {
            error("Request time out");
            yield break;
        }
        yield return www;
        var response = new CNetResponse();
        response.www = www;
        if (www.bytes.Length > 0)
        {
            complete(response);
        }
        else
        {
            error(www.error);
        }
    }
开发者ID:co-chi-tam,项目名称:The-Dark-Creature,代码行数:27,代码来源:CNetRequest.cs

示例15: GetAd

    public IEnumerator GetAd(int id)
    {
		BusinessCard = null;
        adReady = false;
        hasAd = false;
        BusinessID = id;
        string adURL = serverURL + "getAd?b=" + id;
        string bcURL = serverURL + "bizcard?id=" + id;

        WWW card = new WWW(bcURL);
        yield return card;
        BusinessCard = new Texture2D(Convert.ToInt32(card.texture.width),
                              Convert.ToInt32(card.texture.height),
                              TextureFormat.ARGB32, false);
        BusinessCard.SetPixels(card.texture.GetPixels());
        BusinessCard.Apply();

        WWW page = new WWW(adURL);
        yield return page;
        if (page.error == null && page.text[0] == '{')
        {
            Debug.Log(page.text);
            // Get the ad as a Dictionary object.
            hasAd = true;
            Dictionary<string, object> ad = Json.Deserialize(page.text) as Dictionary<string, object>;
            AdImages(ad);
            AdInfo = new AdData(ad);
        }

        adReady = true;
    }
开发者ID:uvcteam,项目名称:univercity3d_uofo,代码行数:31,代码来源:AdManager.cs


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