SettingSocketUrl.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /****************************
  2. summary:
  3. ****************************/
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. public class SettingSocketUrl : MonoBehaviour
  8. {
  9. public SCButton button;
  10. public TextMesh text;
  11. public GameObject settingUrl;
  12. private int clickNum =0;
  13. private void Start()
  14. {
  15. button.onClick.AddListener(OpenOnClick);
  16. if(PlayerPrefs.HasKey("SocketUrl"))
  17. {
  18. if(PlayerPrefs.GetInt("SocketUrl") ==1)
  19. {
  20. GameEnum.ServerHttpURL = "http://10.81.9.12:3437/server/"; // 本地
  21. text.text = "当前版本为:本地";
  22. }
  23. else
  24. {
  25. GameEnum.ServerHttpURL = "http://office.ghz-tech.com:3437/server/"; // 云端
  26. text.text = "当前版本为:云端";
  27. }
  28. }
  29. else
  30. {
  31. PlayerPrefs.SetInt("SocketUrl", 1);
  32. text.text = "当前版本为:本地";
  33. }
  34. }
  35. private void OpenOnClick()
  36. {
  37. clickNum++;
  38. if(clickNum>5)
  39. {
  40. clickNum = 0;
  41. settingUrl.SetActive(true);
  42. Debug.Log("打开 Url设置");
  43. }
  44. }
  45. public void SetUrl( int num)
  46. {
  47. if(num == 1)
  48. {
  49. GameEnum.ServerHttpURL = "http://10.81.9.12:3437/server/"; // 本地
  50. text.text = "当前版本为:本地";
  51. }
  52. else
  53. {
  54. GameEnum.ServerHttpURL = "http://office.ghz-tech.com:3437/server/"; // 云端
  55. text.text = "当前版本为:云端";
  56. }
  57. PlayerPrefs.SetInt("SocketUrl", num);
  58. }
  59. }