应用程序适用于PC但不适用于Android

时间:2014-01-30 16:30:54

标签: android unity3d

我使用Unity3D创建了一个应用程序。在开发了几个星期之后,我尝试生成一个apk并在我的SGII上测试它。

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";

                }
            }

由于我不知道发生了什么,所以无法更好地解释自己。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

昨天,我开始在我的代码中放置大量标签,最后发现它停在哪里。

它只是取代了......

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

...通过

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

当用于设置路径时,只有Windows支持此栏“\”,但我一直在想这个错误是在OnGUI函数中的某个地方。

非常感谢所有来帮助我的人:)

答案 1 :(得分: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位模式下使用Unity并显示色带编辑:添加了一个解决方法来解决GS2图形驱动程序,我不知道是否可以是否与此问题有关)

Unity3D Android Limitations