dongsuoxi1790 2016-04-07 17:55
浏览 125

Unity WWW请求可以使用多个吗?

I have following code in game. The game checks the winner and loser and send the values to the database. The problem now is, that the game only calls 1 WWW Request wiich is strange.

if (playerDataScript.playerTeam == playerStScript.playerTeam)
        {
            GetComponent<AudioSource>().PlayOneShot(loseClip);
            Debug.Log ("You Lost");
                okayButton.SetActive (true);
                WWWForm form1 = new WWWForm ();
                form1.AddField ("user", PlayerPrefs.GetString (LoginSystem.Settings.accountKey.ToString ()));
                form1.AddField ("lose", "1");
                form1.AddField ("gold", Random.Range(50,71));
                form1.AddField("rating", Random.Range(17,31)); // Minus
                WWW saveData1 = new WWW ("http://81.169.176.129/datasavelose.php",form1);
                yield return saveData1;
        }
        else
        {
            GetComponent<AudioSource>().PlayOneShot(winClip);
                okayButton.SetActive (true);
                WWWForm form = new WWWForm ();
                form.AddField ("user", PlayerPrefs.GetString (LoginSystem.Settings.accountKey.ToString ()));
                form.AddField ("win", "1");
                form.AddField ("gold", Random.Range(60,81));
                form.AddField("rating", Random.Range(17,31)); // plus
                WWW saveData = new WWW ("http://81.169.176.129/datasave.php",form);
                yield return saveData;
        }

My question: can i use 2 WWW Request with 2 different php files in the same script?

  • 写回答

1条回答 默认 最新

  • dongzi1397 2016-04-07 20:01
    关注

    Yes you can do multiple WWW requests at once.

    Are you sure it is getting into the else block? (That, and that you are calling it more than once!)

    Most of the time it's the little things that trip me up :)

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度