Пример #1
0
    void Awake()
    {
        DontDestroyOnLoad(this.gameObject);

        Debugger.setDebugLevel(LogSeverity.Log);

        Bugly.SetGameObjectForCallback(GameObjectForCallback);
        Bugly.EnableLog(DebugEnable);
        Bugly.RegisterHandler(LogLevel);

        #if UNITY_IPHONE
        Bugly.SetAppVersion(BuglyAppVersionForIOS);
        Bugly.SetChannel(BuglyAppChannelForIOS);
        Bugly.InitSDK(BuglyAppIdForIOS);

        Bugly.SetGameObjectForCallback("Bugly");
        Bugly.SetCrashHappenCallback("_callbackCrashHappen");
        #endif

        #if UNITY_ANDROID
        Bugly.SetAppVersion(AppVersionForAndroid);
        Bugly.SetChannel(AppChannelForAndroid);
        Bugly.SetReportDelayTime(ReportDelayTimeForAndroid);
        Bugly.InitSDK(BuglyAppIdForAndroid);
        #endif
    }
Пример #2
0
    // 初始化Bugly SDK, 也可以在对应的Android或iOS项目中调用API初始化
    void InitBuglySDK()
    {
        // 设置开启Bugly的调式信息开关,发布时请设置为false
        Bugly.EnableLog(true);
        // 设置自动上报的c#错误信息的类型,可设置为Exception,Error等
        Bugly.RegisterHandler(LogSeverity.Exception);

                #if UNITY_IPHONE
        Bugly.SetAppVersion("");
        Bugly.SetChannel("bugly_test");
        Bugly.InitSDK("com.tencent.rqdtest");
                #endif

                #if UNITY_ANDROID
        Bugly.SetAppVersion("");
        Bugly.SetChannel("bugly_test");
        //Bugly.SetReportDelayTime("0");
        Bugly.InitSDK("900004962");
                #endif

        // 如果你已经在Unity项目导出的Android或iOS工程中进行了SDK的初始化,则只需调用此方法完成C#堆栈捕获功能的开启
        Bugly.EnableExceptionHandler();
    }
Пример #3
0
    void OnGUI()
    {
        GUI.skin.button.fontSize = 35;
        // set the base area
        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

        GUILayout.BeginVertical();

        // set the title bar
        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Bugly Unity Demo");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.Space(20);

        // set layout
        GUILayout.BeginVertical();
        GUILayout.Label("Uncaught Exceptions:");
        GUILayout.Space(20);

        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height - 100));
        GUILayout.BeginHorizontal();
        GUILayout.Space(50);
        selGridInt = GUILayout.SelectionGrid(selGridInt, selGridItems, 3, GUILayout.Height(800));
        GUILayout.Space(50);
        GUILayout.EndHorizontal();
        GUILayout.EndScrollView();

        if (selGridInt != selGridIntOld)
        {
            selGridIntOld = selGridInt;

            switch (selGridInt)
            {
            case 0:
                throwException(new System.Exception("Non-fatal: Base C# exception"));
                break;

            case 1:
                throwException(new System.SystemException("Fatal: System exception"));
                break;

            case 2:
                throwException(new System.ApplicationException("Fatal: Application exception"));
                break;

            case 3:
                throwException(new System.ArgumentException(string.Format("Fatal: {0} ", selGridItems [selGridInt])));
                break;

            case 4:
                throwException(new System.FormatException(string.Format("Fatal: {0} ", selGridItems [selGridInt])));
                break;

            case 5: // ignore
                break;

            case 6:
            case 7:
            case 8:
            case 9:
                throwException(new System.MemberAccessException(string.Format("Fatal: {0} ", selGridItems [selGridInt])));
                break;

            case 10:
            case 11: // ignore
                break;

            case 12:
            case 13:
            case 14:
                throwException(new System.IndexOutOfRangeException(string.Format("Non-Fatal: {0} ", selGridItems [selGridInt])));
                break;

            case 15:
            case 16:
            case 17:
            case 18:
            case 19:
            case 20:
                throwException(new System.Exception(string.Format("Fatal: {0} ", selGridItems [selGridInt])));
                break;

            case 21:
            case 22:
            case 23:
                throwException(new System.ArithmeticException(string.Format("Fatal: {0} ", selGridItems [selGridInt])));
                break;

            case 24:
                throwException(new System.OutOfMemoryException("Fatal: OOM"));
                break;

            case 25:
                List <string> nullList = TestList();
                System.Console.WriteLine("Null List length {0}", nullList.Count);
                break;

            case 26:
                try {
                    throwException(new System.InvalidCastException("Non-Fatal: Invalid cast exception"));
                } catch (System.Exception e) {
                    System.Console.Write("Caught a Exception");
                    Bugly.HandleException(e);
                }
                break;

            case 27:
                Debugger.Info("This will throw a devid zero exception");
                int i = 0;
                i = 2 / i;
                break;

            default:
                break;
            }
        }

        GUILayout.EndVertical();

        GUILayout.EndVertical();
        GUILayout.EndArea();

//      GUILayout.BeginArea (new Rect(Screen.width - 72, 12, 48, 38));
//      if (GUILayout.Button ("Quit", GUILayout.MinHeight (28), GUILayout.MinWidth (48))) {
//          Bugly.PrintLog(LogSeverity.Log,"BuglyUnityDemo - Quit the application");
//          Application.Quit();
//      }
//      GUILayout.EndArea ();
    }
Пример #4
0
    void OnGUI()
    {
        GUI.skin = defaultSkin;
        float scale = 1.0f;

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            //scale = Screen.width / 320;
        }
        //GUI.skin.button.fontSize = Convert.ToInt32(16 * scale);

        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

//		GUILayout.BeginArea (new Rect((Screen.width - 280) / 2,(Screen.height - 320) / 2, 280, 320));
        GUILayout.FlexibleSpace();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        GUILayout.BeginVertical();

        // set the user
        GUILayout.BeginHorizontal();
        GUILayout.Label("User ID :", GUILayout.MinHeight(28 * scale), GUILayout.Width(80 * scale));
        TextUserId = GUILayout.TextField(TextUserId, GUILayout.MinHeight(28 * scale), GUILayout.MinWidth(160 * scale));
        GUILayout.EndHorizontal();

        GUILayout.Space(5 * scale);
        // set the channel
        GUILayout.BeginHorizontal();
        GUILayout.Label("Channel ID :", GUILayout.MinHeight(28 * scale), GUILayout.Width(80 * scale));
        TextChannelId = GUILayout.TextField(TextChannelId, GUILayout.MinHeight(28 * scale), GUILayout.MinWidth(160 * scale));
        GUILayout.EndHorizontal();

        GUILayout.Space(20 * scale);
        GUILayout.BeginHorizontal();
        LogEnable = GUILayout.Toggle(LogEnable, "Log Trigger", GUILayout.MinHeight(28 * scale), GUILayout.Width(80 * scale));
//		GUILayout.Space (10);
        if (GUILayout.Button("Login", GUILayout.MinHeight(28 * scale), GUILayout.MinWidth(160 * scale)))
        {
            if (string.IsNullOrEmpty(TextUserId) || "Input user id".Equals(TextUserId))
            {
                TextTips = "Please input the user id !";
                return;
            }

            TextTips = "";

            if (string.IsNullOrEmpty(TextChannelId) || "Input channel name".Equals(TextChannelId))
            {
                TextChannelId = "channel_bugly_test";
            }

            Bugly.EnableLog(LogEnable);
            Bugly.SetUserId(TextUserId);
            Bugly.SetChannel(TextChannelId);

            Application.LoadLevel(Application.loadedLevel + 1);
        }

        GUILayout.EndHorizontal();

        GUILayout.Label(TextTips, GUILayout.MinHeight(48 * scale));
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();
//		GUILayout.EndArea ();

        GUILayout.EndArea();
    }