私のUnityゲームで私のWebサーバから値を読みたいのですが、私が望む応答が得られません。基本的には、私が示しているアプローチは基本的なデータ型ではうまく動作しますが、オブジェクトの配列(データベースから複数のint値を返す)はありません。WebサーバからのC#の応答が空白(Unity)
void Start()
{
string url = "http://example.com/unitygames/unitywebservice.asmx/GetGameData?='mygamename'";
WWW www = new WWW(url);
StartCoroutine(WaitForRequest2(www));
}
IEnumerator WaitForRequest2(WWW www)
{
yield return www;
if (www.error == null)
{
Debug.Log(www.text);
}
else
{
Debug.Log("Error " + www.text);
}
をとC#のWebサービスでは、私はこれを行う:ユニティで
私はこの(完全なコード)を行う
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public List<Int32> GetGameData(string gameName)
{
List<Int32> myList = new List<Int32>();
SqlConnection connection = new SqlConnection(SQL_CONNECTION);
String selectData = "SELECT STATEMENT HERE ..";
connection.Open();
SqlCommand command = new SqlCommand(selectData, connection)
SqlDataReader reader = command.ExecuteReader();
while (reader.Read()) {
myList.Add(reader.GetInt32(0));
myList.Add(reader.GetInt32(1));
myList.Add(reader.GetInt32(2));
myList.Add(reader.GetInt32(3));
myList.Add(reader.GetInt32(4));
myList.Add(reader.GetInt32(5));
myList.Add(reader.GetInt32(6));
myList.Add(reader.GetInt32(7));
}
connection.Close();
return myList;
}
私がテストしてみたので、Webサービスの一部のコードは、OK作品
そのブラウザで(それは私が欲しいものを返す)が、ユニティで、私は唯一のwww.text応答からこれを取得:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfInt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/" />
UnityEngine.Debug:Log(Object)
<WaitForRequest2>c__Iterator1:MoveNext() (at Assets/Networking.cs:69)
だから私がいない理由www.textから適切な応答を得ますか?私はUnity自身の中で何かを見逃していますか?
EDIT:ブラウザ
クライアント側のコードを共有してもよろしいですか? –
私は自分のコードを編集しました。 – rootpanthera
ブラウザで実行したときにどのような結果が期待されますか? –