游戏在手机上失败但在模拟器中没问题?

时间:2017-01-08 07:57:38

标签: c# unity3d

我正在使用Unity构建AR游戏。我在Unity上测试过它,模拟器也没关系。但是,当我将它作为apk导出并安装在我的Android手机上时,游戏在1级后崩溃了。任何人都有提示吗?

这是Timer Countdown的代码。在此之后,我的游戏崩溃了。

using UnityEngine;
using System.Collections;
using UnityEngine.UI;


public class TimerCountdownL1Win : MonoBehaviour {
    public int timeLeft = 5;
    public Text countdownText;

    void Start ()
    {
        StartCoroutine("LoseTime");
    }

    void Update()
    {
        countdownText.text = ("00:0" + timeLeft);

        if (timeLeft <=0)
        {
            StopCoroutine("LoseTime");
            countdownText.text = "Time's out!";
            //load to new scene
            Application.LoadLevel("Level 1_Win");
         }
    }
    IEnumerator LoseTime()
    {
         while (true)
         {
             yield return new WaitForSeconds(1);
             timeLeft--;
         }
     }
}

错误代码

using UnityEngine;
using System.Collections;


public class GyroCamera : MonoBehaviour {
    private Gyroscope gyro; 
    private bool gyroSupported;
    private Quaternion rotfix; 


    [SerializeField]  
    private Transform worldObj; 
    private float startY; 


    void Start () {
        gyroSupported = SystemInfo.supportsGyroscope; 


        GameObject camParent = new GameObject ("camParent");
        camParent.transform.position = transform.position;
        transform.parent = camParent.transform; 


        if (gyroSupported) {
            gyro = Input.gyro; 
            gyro.enabled = true;


            camParent.transform.rotation = Quaternion.Euler (90f, 180f, 0f); 
            rotfix = new Quaternion (0, 0, 1, 0); 
        }
    }


    void Update () {
        if (gyroSupported && startY == 0) {
            ResetGyroRotation ();
        } 


        transform.localRotation = gyro.attitude * rotfix;
    }

    void ResetGyroRotation() {
        startY = transform.eulerAngles.y; 
        worldObj.rotation = Quaternion.Euler (0f, startY, 0f);
    }
}

Stack Trace

0 个答案:

没有答案