PHPからUnityへデータを受け取ろうとしたところ
下のyield return された resultCompanyphp にエラーが出ていたためPHPのデータが上手く取得できていませんでした
因みにPHPの方で設定したデータはサーバできちんと表示されていました。
PHP
1<?php 2 $CompanyList =array( 3 array( 4 'id' => 0, 5 'text' => "company1", 6 7 ), 8 array( 9 'id' => 1, 10 'text' => "company2", 11 12 ), 13 array( 14 'id' => 2, 15 'text' => "company3", 16 17 ), 18 ); 19 20 $result = json_encode($CompanyList, JSON_UNESCAPED_UNICODE); 21 printf($result); 22?>
C#
1JsonData companyList = LitJson.JsonMapper.ToObject("{}"); 2 3private IEnumerator companyPhp(){ 4 WWWForm date = new WWWForm (); 5 int tempTime = player.getNowTimeInt(); 6 //date.AddField ("id", player.getPlayerid()); 7 WWW resultCompanyphp = new WWW(config.getConnectHTML() + "getCompany.php",date); 8 yield return resultCompanyphp; 9 if (resultCompanyphp.error != null) { 10 Debug.Log("ログインphpにアクセス失敗"); 11 } else { 12 //Debug.Log (resultCompanyphp.text); 13 companyList = JsonMapper.ToObject (resultCompanyphp.text);//会社情報をPHPから取得 14 setCompany ();//会社情報をオブジェクトに再格納する 15 } 16 }
原因が分かる方がいたら教えていただけると嬉しいです
回答1件
あなたの回答
tips
プレビュー