LoginTest.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. public class LoginTest : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10. }
  11. // Update is called once per frame
  12. void Update()
  13. {
  14. if (Input.GetKeyDown(KeyCode.Q))
  15. {
  16. Login("lvjincheng", "19980301");
  17. }
  18. }
  19. private void Login(string user, string password)
  20. {
  21. StartCoroutine(LoginController.Instance.LoginNormal(
  22. user, password, (res) => {
  23. PopupMgr.ins.ShowTip(TextAutoLanguage2.GetTextByCNKey(res.msg));
  24. if (res.code == 0)
  25. {
  26. string loginToken = (string)res.data;
  27. GoToHome(loginToken);
  28. }
  29. }
  30. ));
  31. }
  32. private void GoToHome(string loginToken)
  33. {
  34. CommonConfig.businessServerWsURL = loginToken.Split('&')[2];
  35. PlayerPrefs.SetString(LoginMgr.LoginTokenKey, loginToken);
  36. SceneManager.LoadScene("Home", LoadSceneMode.Single);
  37. }
  38. }