ActiveQuestUIDebugger.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using UnityEngine;
  2. /// <summary>
  3. /// Enhanced debug helper for testing the click management system specifically for ActiveQuestUI.
  4. /// This provides detailed debugging information to help troubleshoot click blocking issues.
  5. /// </summary>
  6. public class ActiveQuestUIDebugger : MonoBehaviour
  7. {
  8. [Header("Debug Settings")]
  9. public bool enableDebugMode = false;
  10. public bool showClickDetails = true;
  11. public bool showUIBounds = true;
  12. public KeyCode testKey = KeyCode.F9;
  13. private ActiveQuestUI activeQuestUI;
  14. void Start()
  15. {
  16. activeQuestUI = FindFirstObjectByType<ActiveQuestUI>();
  17. if (activeQuestUI == null)
  18. {
  19. Debug.LogWarning("ActiveQuestUIDebugger: No ActiveQuestUI found in scene!");
  20. }
  21. // Enable ClickManager debug logs
  22. if (ClickManager.Instance != null)
  23. {
  24. ClickManager.Instance.showDebugLogs = enableDebugMode;
  25. }
  26. }
  27. void Update()
  28. {
  29. if (Input.GetKeyDown(testKey))
  30. {
  31. TestActiveQuestUIBlocking();
  32. }
  33. if (Input.GetMouseButtonDown(0) && showClickDetails)
  34. {
  35. TestSpecificClick();
  36. }
  37. }
  38. void TestActiveQuestUIBlocking()
  39. {
  40. Debug.Log("=== ActiveQuestUI Debug Test ===");
  41. if (activeQuestUI == null)
  42. {
  43. Debug.LogError("❌ ActiveQuestUI not found!");
  44. return;
  45. }
  46. Debug.Log($"✅ ActiveQuestUI found");
  47. Debug.Log($"📊 IsVisible: {activeQuestUI.IsVisible}");
  48. // Test ClickManager registration
  49. if (ClickManager.Instance != null)
  50. {
  51. Debug.Log($"🔧 ClickManager blockers count: {ClickManager.Instance.GetRegisteredBlockersCount()}");
  52. ClickManager.Instance.ListRegisteredBlockers();
  53. }
  54. else
  55. {
  56. Debug.LogError("❌ ClickManager not available!");
  57. }
  58. // Test a specific screen position (center of screen)
  59. Vector2 centerScreen = new Vector2(Screen.width / 2f, Screen.height / 2f);
  60. bool wouldBlock = activeQuestUI.IsBlockingClick(centerScreen);
  61. Debug.Log($"🎯 Would block center screen click: {wouldBlock}");
  62. }
  63. void TestSpecificClick()
  64. {
  65. Vector2 mousePos = Input.mousePosition;
  66. Debug.Log($"=== Click Test at {mousePos} ===");
  67. if (activeQuestUI != null)
  68. {
  69. bool questUIBlocks = activeQuestUI.IsBlockingClick(mousePos);
  70. Debug.Log($"📝 ActiveQuestUI blocks: {questUIBlocks}");
  71. Debug.Log($"📊 ActiveQuestUI.IsVisible: {activeQuestUI.IsVisible}");
  72. }
  73. if (ClickManager.Instance != null)
  74. {
  75. bool anyBlocks = ClickManager.Instance.IsClickBlocked(mousePos);
  76. Debug.Log($"🔒 Any UI blocks: {anyBlocks}");
  77. }
  78. }
  79. void OnGUI()
  80. {
  81. if (!showUIBounds || activeQuestUI == null) return;
  82. // Draw UI bounds visualization
  83. GUI.color = Color.red;
  84. GUI.Label(new Rect(10, 10, 400, 20), $"ActiveQuestUI Debug - Visible: {activeQuestUI.IsVisible}");
  85. GUI.Label(new Rect(10, 30, 400, 20), $"ClickManager Blockers: {ClickManager.Instance?.GetRegisteredBlockersCount() ?? 0}");
  86. GUI.Label(new Rect(10, 50, 400, 20), $"Press {testKey} to run detailed test");
  87. GUI.color = Color.white;
  88. }
  89. }