2014-04-03 40 views
0

簡化目前我的問題是這樣的:團結WWW產量請求恢復工作在編輯器,但不是在FB應用

下面

代碼在統一編輯,我已經檢查了PHP多次前,現在的URL發送作品,並且它返回正確的值,但是將一個構建上傳到facebook應用中使用的空間會因爲某種原因而中斷它,img會提供以顯示它停止的位置。

其他一些細節:

環顧所有跡象都表明它是與V3.0(我的是v4.3.3f1使用的版本)中的錯誤,但同時我下面的代碼工作在編輯器沒有問題,當我將它的構建上傳到我提供的html空間時,它不會繼續超過yield return www請求。

當前登錄在下面的塊之前工作的方式是初始化FB gameobject,登錄Facebook,檢查沒有錯誤,然後傳回FB UserID,然後傳遞給下面的代碼 - 它的工作原理如下意。

快速編輯 - 數據庫連接器包含主要的URL,下面的代碼添加到php獲取必要的字符串。

我不知道從哪裏開始嘗試修復它,除了更改顯示的文本,因爲它正在進行,這有助於將它隔離到我的問題。

登錄屏幕的圖片在那裏堅持:http://i.imgur.com/ti2YLrW.png?1

代碼:

using UnityEngine; 

using System.Collections; 

using System; 

public class ConnectToDataBase : MonoBehaviour { 

    public bool bDatabaseConnected = false; 
    public bool bConnectionFailed = false; 

    public string sFacebookID; 
    public WWWForm wwwForm; 

    public void vStartConnection() 
    { 
     var text = GameObject.FindGameObjectWithTag ("Other"); 

     text.guiText.text = "Login : connectToDatabase: prepping query"; 

     //call databasequeries and get sDBConnect 
     string sConnectPhp = GameObject.FindGameObjectWithTag("DBConnector").GetComponent<DatabaseQueries>().sDBConnect; 

     //now ready the url with the necessary code for php's get, and the FacebookID 
     string url = sConnectPhp + "?UserID=" + sFacebookID; 

     text.guiText.text = "Login : connectToDatabase: url being sent:\n" + url; 

     WWW wwwGet = new WWW(url); 

     text.guiText.text = "Login : connectToDatabase: wwwGet created"; 

     text.guiText.text = "Login : connectToDatabase: starting coroutine"; 
     StartCoroutine(Connect(wwwGet)); 
    } 

    IEnumerator Connect(WWW www) 
    { 
     var text = GameObject.FindGameObjectWithTag("Other"); 
     text.guiText.text = "Login : connectToDatabase: coroutine started - sending www request"; 

     yield return www; 

     text.guiText.text = "Login : connectToDatabase: wwwGet yield return"; 

     string sTemp = www.text; 

     if(www.error == null) 
     { 
      text.guiText.text = "Login : connectToDatabase: wwwGet has not errored"; 

      string newString = sTemp.ToString(); 
      int newInt = Convert.ToInt32(newString); 

      //print (newString); 
      text.guiText.text = "Login : connectToDatabase: checking wwwGet return as int"; 

      if(newInt == 0) 
      { 
       //if successfully connected set to true 
       print ("connectToDatabase: olduser successful"); 
       text.guiText.text = "Login : connectToDatabase: olduser successful"; 

       bDatabaseConnected = true; 
       yield break; 
      } 
      else if(newInt == 1) 
      { 
       //if successfully connected set to true 
       print ("connectToDatabase: newuser successful"); 
       text.guiText.text = "Login : connectToDatabase: newuser successful"; 

       bDatabaseConnected = true; 
       yield break; 
      } 
      else if(newInt == 2) 
      { 
       //game connection has failed 
       print ("connectToDatabase: failed"); 
       text.guiText.text = "Login : connectToDatabase: failed"; 
       bDatabaseConnected = false; 
       bConnectionFailed = true; 
       yield break; 
      } 
      else 
      { 
       text.guiText.text = "Login : connectToDatabase: php did not return a 0/1/2 value"; 
      } 
     } 
     else 
     { 
      //game connection has failed 
      print ("connectToDatabase: failed"); 
      text.guiText.text = "Login : connectToDatabase: wwwGet has errored:\n" + www.error; 

      bDatabaseConnected = false; 
      bConnectionFailed = true; 
      yield break; 
     } 

     text.guiText.text = "Login : connectToDatabase: wwwGet if statement skipped entirely"; 
    } 
} 

回答

1

有在瀏覽器中運行時是不同的規則。如上所述here該應用程序處於沙盒模式,因此您需要添加一個crossdomain策略(我知道該鏈接適用於Flash Player,但適用相同的原則)。

最後,您需要這樣的東西,它保存在您的Web服務器根目錄下的crossdomain.xml文件中。

<?xml version="1.0"?> 
<cross-domain-policy> 
<allow-access-from domain="*" secure="false"/> 
</cross-domain-policy> 
+0

Aaah好的謝謝,明天我再次在實驗室裏實施它。 – BigHandInSky

相關問題