ModuleGuestManager.cs 2.4 KB

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