TaptapAntiAddictionRetryAlertController.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using UnityEngine.UI;
  3. using TapSDK.UI;
  4. using TapTap.AntiAddiction;
  5. namespace TapTap.AntiAddiction.Internal {
  6. public class TaptapAntiAddictionRetryAlertController : BasePanelController
  7. {
  8. public Text messageText;
  9. public Text buttonText;
  10. public Button retryButton;
  11. private Action _onRetry;
  12. /// <summary>
  13. /// bind ugui components for every panel
  14. /// </summary>
  15. protected override void BindComponents()
  16. {
  17. messageText = transform.Find("Root/BackgroundImage/MessageText").GetComponent<Text>();
  18. retryButton = transform.Find("Root/BackgroundImage/RetryButton").GetComponent<Button>();
  19. buttonText = retryButton.transform.Find("Text").GetComponent<Text>();
  20. }
  21. protected override void OnLoadSuccess()
  22. {
  23. base.OnLoadSuccess();
  24. buttonText.text = TapTapAntiAddictionManager.LocalizationItems.Current.Retry;
  25. retryButton.onClick.AddListener(OnRetryClicked);
  26. }
  27. private void OnRetryClicked()
  28. {
  29. _onRetry?.Invoke();
  30. Close();
  31. }
  32. internal void Show(string message, Action onRetry)
  33. {
  34. messageText.text = message;
  35. _onRetry = onRetry;
  36. }
  37. }
  38. }