AgreementView.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Networking;
  6. public class AgreementView : MonoBehaviour
  7. {
  8. public void EnterUserAgreement() {
  9. GetTitleText().text = "用户协议";
  10. StartCoroutine(GetUserAgreement());
  11. }
  12. public void EnterPrivacyAgreement() {
  13. GetTitleText().text = "隐私政策";
  14. StartCoroutine(GetPrivacyAgreement());
  15. }
  16. Text GetTitleText() {
  17. return transform.Find("Title").GetComponent<Text>();
  18. }
  19. Text GetContentText(string id = "") {
  20. return transform.Find("ScrollView/Viewport/Content" + id).GetComponent<Text>();
  21. }
  22. public void Back() {
  23. Destroy(gameObject);
  24. }
  25. //http
  26. IEnumerator GetUserAgreement() {
  27. string url = CommonConfig.businessServerURI + "/app/getUserAgreement";
  28. UnityWebRequest request = UnityWebRequest.Get(url);
  29. yield return request.SendWebRequest();
  30. if (request.result == UnityWebRequest.Result.Success) {
  31. GetContentText().text = "\n" + request.downloadHandler.text;
  32. }
  33. }
  34. IEnumerator GetPrivacyAgreement() {
  35. string url = CommonConfig.businessServerURI + "/app/getPrivacyAgreement";
  36. UnityWebRequest request = UnityWebRequest.Get(url);
  37. yield return request.SendWebRequest();
  38. if (request.result == UnityWebRequest.Result.Success) {
  39. GetContentText().text = "\n" + request.downloadHandler.text;
  40. }
  41. }
  42. }