ModuleGuestView.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using AppUI.Manager.View;
  2. using DG.Tweening;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using TMPro;
  6. using UnityEngine;
  7. using UnityEngine.Events;
  8. using UnityEngine.UI;
  9. namespace AppUI.View.Component
  10. {
  11. public class ModuleGuestView : MonoBehaviour
  12. {
  13. public string text;
  14. public string textKey;
  15. public object[] textFormatArgs = { };
  16. public UnityAction onLogin;
  17. //public string onAgreeTextKey;
  18. public UnityAction onSignUp;
  19. //public string onRejectTextKey;
  20. public UnityAction onGuestMode;
  21. public bool willDestroyAfterClick = true;
  22. public static ModuleGuestView Show()
  23. {
  24. GameObject o = Instantiate(ViewManager.GetPrefabByType(UIPrefabType.ModuleGuestView));
  25. ModuleGuestView v = o.AddComponent<ModuleGuestView>();
  26. return v;
  27. }
  28. void Start()
  29. {
  30. //if (textKey != null)
  31. //{
  32. // TextAutoLanguage2 t2 = transform.Find("Frame/Text").gameObject.AddComponent<TextAutoLanguage2>();
  33. // t2.textFormatArgs = textFormatArgs;
  34. // t2.SetTextKey(textKey);
  35. //}
  36. //else
  37. //{
  38. // transform.Find("Frame/Text").GetComponent<TMP_Text>().text = text;
  39. //}
  40. Transform BtnLogin = transform.Find("Frame/BtnLogin");
  41. BtnLogin.GetComponent<Button>().onClick.AddListener(() => {
  42. onLogin?.Invoke();
  43. if (willDestroyAfterClick) Destroy(gameObject);
  44. });
  45. Transform BtnSignUp = transform.Find("Frame/BtnSignUp");
  46. BtnSignUp.GetComponent<Button>().onClick.AddListener(() => {
  47. onSignUp?.Invoke();
  48. if (willDestroyAfterClick) Destroy(gameObject);
  49. });
  50. Transform BtnGuestMode = transform.Find("Frame/BtnGuestMode");
  51. BtnGuestMode.GetComponent<Button>().onClick.AddListener(() => {
  52. onGuestMode?.Invoke();
  53. if (willDestroyAfterClick) Destroy(gameObject);
  54. });
  55. //if (!string.IsNullOrEmpty(onAgreeTextKey))
  56. //{
  57. // btnAgree.GetComponentInChildren<TextAutoLanguage2>().SetTextKey(onAgreeTextKey);
  58. //}
  59. //if (!string.IsNullOrEmpty(onRejectTextKey))
  60. //{
  61. // btnReject.GetComponentInChildren<TextAutoLanguage2>().SetTextKey(onRejectTextKey);
  62. //}
  63. }
  64. }
  65. }