2014-01-30 21 views
1

我使用Unity3D創建了一個應用程序。開發了幾個星期後,我嘗試生成一個apk並在我的SGII上進行測試。(已解決)應用程序在PC上運行,但不在Android中

Unity在本地測試應用程序時不會返回錯誤或警告,但在我的手機上運行時,它不起作用。

有2個按鈕(1時鐘輸入和1時鐘輸出)。按鈕1會在您輸入日期時輸入日期,並切換布爾值以允許您輸出時鐘。在我的手機中運行時,按鈕1工作正常,但按鈕2沒有。該按鈕實際上工作,因爲它返回每個debug.log,但沒有別的。

我的代碼如下所示:

function OnGUI() 
{ 
GUI.skin = skin; 

if(Functions.firstTime == 0) 
{ 
     Functions.setupWiz(); 
} 


switch(currentMenu) 
{ 
    case 1: 

     GUI.BeginGroup(Rect(0, 0, width, height)); 


      if(Functions.birthday == true) 
      { 
       debugLog11 = "\n"+happyBirthdayMsg+", "+Functions.userName+"!"; 
       Functions.birthday = false; 
      } 


      if(GUI.Button(Rect(buttonTopHMargin,height*.1f + buttonTopVMargin, width*.24f, height*.1f), "ENTRADA", "Box")) 
      { 
       if(!clockedIn && clockedOut) 
       { 
        var clockIn = Functions.clockIn(); 
        debugLog11 = "\nHora de entrada"; 
        debugLog12 = "\n"+clockIn[3]+":"+clockIn[4]+":"+clockIn[5]; 
        clockedIn = true; 
        clockedOut = false; 
       } 
       else 
       { 
        debugLog11 = "\n"+errorMsg1; 
        debugLog12 = "\n"; 
       } 
      } 





      if(GUI.Button(Rect(width - buttonTopHMargin - width*.24f, height*.1f + buttonTopVMargin, width*.24f, height*.1f), "SALIDA", "Box")) 
      { 
       if(!clockedOut && clockedIn) 
       { 
//     debugLog11 = clockedIn+"\n"+clockedOut; 
        Functions.clockOut(); 
        var clockOut = Functions.clockOut(); 
        var workedSecondsToday : Array = Functions.calculateDay(); 
        var workedTimeToday = Functions.convertSeconds(parseInt(workedSecondsToday[0].ToString())); 
        var extraTimeToday = Functions.convertSeconds(parseInt(workedSecondsToday[1].ToString())); 
        var festTimeToday = Functions.convertSeconds(parseInt(workedSecondsToday[2].ToString())); 
        if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) < 1 && parseInt(workedSecondsToday[2].ToString()) < 1) 
        { 
         debugLog11 = "\nHora de Salida\nNormal:"; //NORMAL 
         debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]; 

        } 
        else if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) > 0 && parseInt(workedSecondsToday[2].ToString()) < 1) 
        { 
         debugLog11 = "\nHora de Salida\nNormal:\nExtra:"; //NORMAL + EXTRA 
         debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]+"\n"+extraTimeToday[0]+"-"+extraTimeToday[1]+":"+extraTimeToday[2]+":"+extraTimeToday[3];; 

        } 
        else if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) < 1 && parseInt(workedSecondsToday[2].ToString()) > 0) 
        { 
         debugLog11 = "\nHora de Salida\nNormal:\nFestivo:"; //NORMAL + FESTIVO 
         debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]+"\n"+festTimeToday[0]+"-"+festTimeToday[1]+":"+festTimeToday[2]+":"+festTimeToday[3]; 

        } 
        else if(parseInt(workedSecondsToday[0].ToString()) > 0 && parseInt(workedSecondsToday[1].ToString()) > 0 && parseInt(workedSecondsToday[2].ToString()) > 0) 
        { 
         debugLog11 = "\nHora de Salida\nNormal:\nExtra:\nFestivo:"; //NORMAL + EXTRA + FESTIVO 
         debugLog12 = "\n"+clockOut[3]+":"+clockOut[4]+":"+clockOut[5]+"\n"+workedTimeToday[1]+":"+workedTimeToday[2]+workedTimeToday[3]+"\n"+extraTimeToday[0]+"-"+extraTimeToday[1]+":"+extraTimeToday[2]+":"+extraTimeToday[3]+"\n"+festTimeToday[0]+"-"+festTimeToday[1]+":"+festTimeToday[2]+":"+festTimeToday[3]; 
        } 
        clockedOut = true; 
        clockedIn = false; 
       } 
       else 
       { 
        debugLog01 = mainMsg; 
        debugLog11 = "\n"+errorMsg2; 
        debugLog12 = "\n"; 

       } 
      } 

無法解釋自己更好,因爲我不知道發生了什麼線索。任何幫助都感激不盡。

+0

在android上調試您的應用程序,並查看在LogCat中打印的消息。 – Jorgesys

+0

感謝您的快速回復!我已經試過這個,但android調試監視器說:「無法打開日誌設備'/ dev/log/main':沒有這樣的文件或目錄」。而因爲我從來沒有使用Android SDK,或Eclipse或任何這些應用程序喲不能讓它運行。也嘗試過與我的gf的SGI同樣的結果。 – Calfa

+0

嘗試:http://forum.xda-developers.com/showpost.php?p=17774398&postcount=93 – Jorgesys

回答

0

在Unity3D你可以找到這樣的信息:

Work with specific constraints (constraint): 

Samsung Galaxy S (30 MB limit to downloadable file size, also problems with UI) 
Samsung Galaxy Tab (30 MB limit to downloadable file size) 
HTC Desire (40 MB limit to downloadable file size) 
Samsung Galaxy S2 (Minor but possibly annoying issue: phone may work in 16-bit mode with Unity and show color banding Edit: a workaround was added to address the GS2 graphics driver, I don't know if it was related to this problem or not) 
HTC EVO3D (Must build with Unity 3.4) 
HTC Sensation (Must build with Unity 3.4) 

三星Galaxy S2(小但可能惱人的問題:手機可能會在16位模式下工作,團結和展示色帶編輯:一種解決方法是加入到解決GS2顯卡驅動程序,我不知道這是否是與此相關的問題或沒有)

Unity3D Android Limitations

+0

該應用程序在手機上運行。其餘的按鈕看起來和工作正常。它只是這兩個按鈕相互依賴,不按預期工作。 – Calfa

+0

應用程序只有9MB,它基本上只是一堆GUI元素。 – Calfa

+0

它寫道這款手機有問題:Samsung Galaxy S2 –

0

昨天,我開始把噸的標籤無處不在我的代碼,並最終發現它停在哪裏。

這只是更換此...

var sw = new StreamWriter(Application.persistentDataPath+"\\Settings.txt", false); 

由...

var sw = new StreamWriter(Application.persistentDataPath+"/Settings.txt", false); 

只有Windows支持用於設置路徑時,這條 「\」,但我想所有的該錯誤在OnGUI函數中的某處。

非常感謝所有來幫助我的人:)

相關問題