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

标签 android unity-game-engine

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

在本地测试应用程序时,Unity 没有返回任何错误或警告,但是当它在我的手机上运行时,它不起作用。

有 2 个按钮(1 个用于打卡,1 个用于打卡下类)。按钮 1 获取您签到的日期,并切换一个 bool 值以允许您 checkout 。在我的手机上运行时,按钮 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";

                }
            }

无法更好地解释自己,因为我对正在发生的事情一无所知。任何帮助将不胜感激。

最佳答案

昨天,我开始在我的代码中到处放置大量标签,并最终找到了它停止的地方。

它只是取代了这个......

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

通过...

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

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

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

关于android - 应用程序适用于 PC 但不适用于 Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21462075/

相关文章:

android - 如何合并/合并两个 aar 文件?

android - 为 App 设置自定义主题时 TextInputLayout 崩溃

带有 php 文件登录详细信息的 Android POST 数据 - https

unity-game-engine - AnimationCurve.Evaluate - 按值获取时间

ios - 如何将网格的每个顶点绘制为圆

c# - 变量 previousValue 返回 NullReferenceException : Object not set to an instance of object

android - 当子弹击中某物时,如何在 Unity 中摇晃相机?

java - 未处理的异常类型 JSONException

android - 适用于 Android 的 Visual Studio 模拟器无法正常工作 : mscorlib. dll.so 未找到

c# - 在 Unity 中,改变 x 和 y 旋转也会奇怪地改变 z 值