示例#1
0
 // Awake
 void Awake()
 {
     _bugReportStep = ErrGuiStep.Step_Idle;
     DontDestroyOnLoad(this);
 }
示例#2
0
    void OnGUI()
    {
        GUI.skin  = GSkin;
        GUI.depth = -1000;
        switch (_bugReportStep)
        {
        default:
        case ErrGuiStep.Step_Idle:
            if (_strRuntimeError.Length > 0)
            {
                Time.timeScale = 0;

                GUI.Label(new Rect(0, 0, Screen.width, Screen.height), "", "BlackMask");
                GUI.Label(new Rect(40, 40, 24, 24), "", "ErrorTip");
                GUI.Label(new Rect(70, 46, Screen.width - 140, Screen.height - 70), _strRuntimeError, "WhiteVerdanaText");
                Rect rect = new Rect((Screen.width - 566) / 2, (Screen.height - 156) / 2, 566, 156);
                GUI.BeginGroup(rect, "", "MsgBoxWindow");
                // Title / Caption
                GUI.Label(new Rect(1, 7, rect.width, 26), "System Error", "MsgCaptionTextSD");
                GUI.Label(new Rect(0, 6, rect.width, 26), "System Error", "MsgCaptionText");

                // Content
                GUI.Label(new Rect(25, 46, 48, 48), "", "ErrorSignal");
                GUI.Label(new Rect(88, 59, 450, 90), _strListInUse[(int)EStr.ErrorOccured], "WhiteVerdanaText");

                int button_x_begin = ((int)rect.width - 108) / 2;

                if (GUI.Button(new Rect(button_x_begin - 100, 112, 108, 24), _strListInUse[(int)EStr.Quit], "ButtonStyle"))
                {
                    _bugReportStep = ErrGuiStep.Step_QuitGame;
                }
                if (GUI.Button(new Rect(button_x_begin + 100, 112, 108, 24), _strListInUse[(int)EStr.SendReport], "ButtonStyle"))
                {
                    _bugReportStep = ErrGuiStep.Step_Report;
                }
                GUI.EndGroup();
            }
            else if (!string.IsNullOrEmpty(_strToThrowToMainThread))
            {
                Debug.LogError(_strToThrowToMainThread);
                _strToThrowToMainThread = string.Empty;
            }
            break;

        case ErrGuiStep.Step_Report:
            if (true)
            {
                Time.timeScale = 0;

                GUI.Label(new Rect(0, 0, Screen.width, Screen.height), "", "BlackMask");
                GUI.Label(new Rect(40, 40, 24, 24), "", "ErrorTip");
                GUI.Label(new Rect(70, 46, Screen.width - 140, Screen.height - 70), _strRuntimeError, "WhiteVerdanaText");

                Rect rect = new Rect((Screen.width - 566) / 2, (Screen.height - 156) / 2, 566, 156);
                GUI.BeginGroup(rect, "", "MsgBoxWindow");
                // Title / Caption
                GUI.Label(new Rect(1, 7, rect.width, 26), "System Error", "MsgCaptionTextSD");
                GUI.Label(new Rect(0, 6, rect.width, 26), "System Error", "MsgCaptionText");

                GUI.Label(new Rect(12, 36, 240, 20), _strListInUse[(int)EStr.StepsToReproduce], "WhiteVerdanaText");
                _reproduceDesc = GUI.TextArea(new Rect(20, 56, 526, 60), _reproduceDesc);
                int button_x_begin = ((int)rect.width - 108) / 2;
                if (BugReporter.IsSending)
                {
                    string strSending = _strListInUse[(int)EStr.Sending];
                    int    len        = ((int)Time.realtimeSinceStartup) % (strSending.Length);
                    GUI.Button(new Rect(button_x_begin, 116, 108, 24), strSending.Substring(0, len), "ButtonStyle");
                }
                else if (GUI.Button(new Rect(button_x_begin, 116, 108, 24), _strListInUse[(int)EStr.SendAndQuit], "ButtonStyle"))
                {
                    BugReporter.SendEmailAsync(_strRuntimeError + "\nReproduce Steps:\n" + _reproduceDesc, 5, delegate { _bugReportStep = ErrGuiStep.Step_QuitGame; });
                }
                GUI.EndGroup();
            }
            break;

        case ErrGuiStep.Step_QuitGame:
            _bugReportStep = ErrGuiStep.Step_Dying;
            Debug.Log(_lastLogTime.ToString("G") + "[Quit Game Unexpectedly]");
            Application.Quit();
#if UNITY_EDITOR
            Time.timeScale = 1;
            //Application.RegisterLogCallback(null);
#endif
            break;

        case ErrGuiStep.Step_Dying:
            // Donothing but dying
            break;
        }

#if SAVE_GAME_LOG
        if (bShowLog)
        {
            GUI.Label(new Rect(0, Screen.height - 380, Screen.width, 380), "", "BottomBG3ZX");
            GUI.Label(new Rect(-20, Screen.height - 375, Screen.width, 20), "Game Logs:", "LogTip");
            scrollViewPos = GUI.BeginScrollView(new Rect(0, Screen.height - 350, Screen.width - 8, 246), scrollViewPos, new Rect(0, 0, Screen.width - 20, Logs.Count * 25));
            for (int i = 0; i < Logs.Count; i++)
            {
                if (Logs[i].Type == LogType.Log)
                {
                    GUI.Label(new Rect(12, i * 25, Screen.width - 100, 25), Logs[i].LogTime.ToShortTimeString() + "\t\t" + Logs[i].LogString, "LogTip");
                    GUI.Label(new Rect(Screen.width - 80, i * 25, 50, 25), Logs[i].Count.ToString(), "LogTip");
                }
                else if (Logs[i].Type == LogType.Warning)
                {
                    GUI.Label(new Rect(12, i * 25, Screen.width - 100, 25), Logs[i].LogTime.ToShortTimeString() + "\t\t" + Logs[i].LogString, "WarningTip");
                    GUI.Label(new Rect(Screen.width - 80, i * 25, 50, 25), Logs[i].Count.ToString(), "WarningTip");
                }
                else
                {
                    GUI.Label(new Rect(12, i * 25, Screen.width - 100, 25), Logs[i].LogTime.ToShortTimeString() + "\t\t" + Logs[i].LogString, "ErrorTip");
                    GUI.Label(new Rect(Screen.width - 80, i * 25, 50, 25), Logs[i].Count.ToString(), "ErrorTip");
                }
                if (GUI.Button(new Rect(Screen.width - 155, i * 25 + 2, 73, 22), "Detail", "ButtonStyle"))
                {
                    Detail = Logs[i].StackTrace;
                }
            }
            GUI.EndScrollView();
            GUI.Label(new Rect(0, Screen.height - 350, Screen.width, 250), "", "NumberInput");
            GUI.TextField(new Rect(4, Screen.height - 99, Screen.width - 8, 98), Detail, "WhiteVerdanaText");
            GUI.Label(new Rect(0, Screen.height - 100, Screen.width, 100), "", "NumberInput");
        }
#endif
    }