private void OnGUI()
    {
        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.fontSize = 40;

        if (GUI.Button(new Rect(60, 150, 180, 100), "登录", style))
        {
            UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(1);
        }

        if (GUI.Button(new Rect(60, 300, 180, 100), "动态", style))
        {
            UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(2);
        }

        if (GUI.Button(new Rect(60, 450, 180, 100), "TapDB", style))
        {
            Loom.Initialize();
            TDSLogin.GetCurrentProfile((profile) => {
                if (profile == null)
                {
                    UnityNativeToastsHelper.ShowShortText("当前未登录");
                }
                else
                {
                    Loom.QueueOnMainThread((param) => {
                        UnityEngine.SceneManagement.SceneManager.LoadScene(3);
                    }, null);
                }
            });
        }
    }
 public void LoginError(TDSAccountError error)
 {
     Debug.Log("登录失败的error信息:  " + error.error);
     if (error.error == "access_denied" || error.error == "forbidden" || error.error == "invalid_grant")
     {
         if (!isFlag)
         {
             reLogin();
         }
     }
     else
     {
         isFlag = false;
         UnityNativeToastsHelper.ShowShortText("登录失败: " + error.error);
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        TDSCore.EnableMoment();

        TDSMoment.SetCallback((code, msg) =>
        {
            Debug.Log("---- moment 回调  code: " + code + " msg: " + msg + "----");
            if (code == 20100)
            {
                UnityNativeToastsHelper.ShowShortText("获取新消息失败");
            }
            else if (code == 20000)
            {
                UnityNativeToastsHelper.ShowShortText("获取新消息成功");
            }
        });
    }
Esempio n. 4
0
    // Start is called before the first frame update
    void Start()
    {
        TapMoment.FetchNotification();


        TapMoment.SetCallback((code, msg) =>
        {
            Debug.Log("---- moment 回调  code: " + code + " msg: " + msg + "----");
            if (code == 20100)
            {
                UnityNativeToastsHelper.ShowShortText("获取新消息失败");
            }
            else if (code == 20000)
            {
                UnityNativeToastsHelper.ShowShortText("获取新消息成功: " + msg);
            }
        });
    }
Esempio n. 5
0
    private void OnGUI()
    {
        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.fontSize = 40;

        GUI.depth = 0;

        if (GUI.Button(new Rect(60, 150, 180, 100), "登录", style))
        {
            TDSLogin.GetCurrentProfile((profile) => {
                if (profile == null)
                {
                    string[] permissions = { "public_profile" };
                    TDSLogin.StartLogin(permissions);
                }
                else
                {
                    UnityNativeToastsHelper.ShowShortText("已经登录");
                }
            });
        }

        if (GUI.Button(new Rect(60, 300, 180, 100), "退出登录", style))
        {
            TDSLogin.GetCurrentProfile((profile) => {
                if (profile == null)
                {
                    UnityNativeToastsHelper.ShowShortText("当前未登录");
                }
                else
                {
                    UnityNativeToastsHelper.ShowShortText("退出登录");
                    TDSLogin.Logout();
                }
            });
        }

        if (GUI.Button(new Rect(60, 450, 180, 100), "用户信息", style))
        {
            TDSLogin.GetCurrentProfile((profile) => {
                if (profile == null)
                {
                    UnityNativeToastsHelper.ShowShortText("当前未登录");
                }
                else
                {
                    string str = profile.ToJSON();
                    UnityNativeToastsHelper.ShowShortText(str);
                }
            });
        }

        if (GUI.Button(new Rect(60, 600, 260, 100), "远程用户信息", style))
        {
            TDSLogin.FetchProfileForCurrentAccessToken((profile) => {
                if (profile == null)
                {
                    UnityNativeToastsHelper.ShowShortText("当前未登录");
                }
                else
                {
                    string str = profile.ToJSON();
                    UnityNativeToastsHelper.ShowShortText(str);
                }
            }, (error) => {
                UnityNativeToastsHelper.ShowShortText(error);
            });
        }

        if (GUI.Button(new Rect(60, 750, 180, 100), "返回", style))
        {
            UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(0);
        }
    }
 public void LoginCancel()
 {
     isFlag = false;
     UnityNativeToastsHelper.ShowShortText("取消登录");
 }
 public void LoginSuccess(TDSAccessToken accessToken)
 {
     isFlag = false;
     UnityNativeToastsHelper.ShowShortText("登录成功");
     setDBUser();
 }