从Unity3D Android游戏中将得分保存到MS SQL数据库中

时间:2014-06-18 11:52:28

标签: c# android sql-server asp.net-mvc-4 unity3d

我正在尝试将分数保存到MS SQL数据库中。

我创建了 ASP.NET MVC Web应用程序,当我尝试调用特定的URL时:

www.mydomain.com/controller/action吗

whit特定参数:

命名= somename&安培;分值= somescore

得分将被保存。

在统一 C#脚本中,我使用了 WWW API。这是代码:

using UnityEngine;
using System.Collections;

public class ShowScore : MonoBehaviour {


public string addScoreURL = "http://www.mydomain.com/controller/action?";
string score=SomeStaticClass.Score;


void Start ()
{
    string name=SystemInfo.deviceName+"_"+SystemInfo.deviceModel;
    StartCoroutine(PostScores(name,score));
}

IEnumerator PostScores(string name, int score)
{

    string post_url = addScoreURL + "name=" + WWW.EscapeURL(name) + "&score=" + score ;

    WWW hs_post = new WWW(post_url);
    yield return hs_post; // Wait until the download is done

    if (hs_post.error != null)
    {
        print("There was an error posting the high score: " + hs_post.error.ToUpper());
    }
}

为了测试我为 windows web android 构建应用程序。一切正常用于Windows和Web,但 android 应用程序无法将分数保存到数据库中。

可能有什么问题?

1 个答案:

答案 0 :(得分:0)

Abit迟到回答但使用它可能是您的数据库速度的问题