SettlementGameObjectDiagnostic.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. /// <summary>
  3. /// Detailed diagnostic script to check what components are actually on GameObjects
  4. /// </summary>
  5. public class SettlementGameObjectDiagnostic : MonoBehaviour
  6. {
  7. [ContextMenu("Diagnose Settlement GameObjects")]
  8. public void DiagnoseGameObjects()
  9. {
  10. Debug.Log("=== SETTLEMENT GAMEOBJECT DIAGNOSTIC ===");
  11. // Find all GameObjects with settlement-related names
  12. var allObjects = FindObjectsByType<GameObject>(UnityEngine.FindObjectsSortMode.None);
  13. foreach (var obj in allObjects)
  14. {
  15. if (obj.name.Contains("Settlement") || obj.name.Contains("settlement"))
  16. {
  17. Debug.Log($"\n🎯 GameObject: '{obj.name}'");
  18. Debug.Log($" Active: {obj.activeInHierarchy}");
  19. Debug.Log($" Tag: {obj.tag}");
  20. // List all components
  21. var components = obj.GetComponents<Component>();
  22. Debug.Log($" Components ({components.Length}):");
  23. foreach (var comp in components)
  24. {
  25. if (comp != null)
  26. {
  27. Debug.Log($" - {comp.GetType().Name}");
  28. }
  29. }
  30. }
  31. }
  32. Debug.Log("\n=== SPECIFIC COMPONENT SEARCH ===");
  33. // Search for specific components
  34. var settlementManager = FindFirstObjectByType<SettlementInteractionManager>();
  35. var settlementUI = FindFirstObjectByType<SettlementInteractionUI>();
  36. var settlementBridge = FindFirstObjectByType<SettlementUIBridge>();
  37. Debug.Log($"SettlementInteractionManager found: {settlementManager != null}");
  38. if (settlementManager != null)
  39. {
  40. Debug.Log($" On GameObject: '{settlementManager.gameObject.name}'");
  41. }
  42. Debug.Log($"SettlementInteractionUI found: {settlementUI != null}");
  43. if (settlementUI != null)
  44. {
  45. Debug.Log($" On GameObject: '{settlementUI.gameObject.name}'");
  46. }
  47. Debug.Log($"SettlementUIBridge found: {settlementBridge != null}");
  48. if (settlementBridge != null)
  49. {
  50. Debug.Log($" On GameObject: '{settlementBridge.gameObject.name}'");
  51. Debug.Log($" Settlement UI Reference: {settlementBridge.settlementUI != null}");
  52. }
  53. Debug.Log("\n=== UI DOCUMENT SEARCH ===");
  54. // Check for UIDocument components
  55. var uiDocuments = FindObjectsByType<UnityEngine.UIElements.UIDocument>(UnityEngine.FindObjectsSortMode.None);
  56. Debug.Log($"Found {uiDocuments.Length} UIDocument components:");
  57. foreach (var uiDoc in uiDocuments)
  58. {
  59. Debug.Log($" UIDocument on '{uiDoc.gameObject.name}'");
  60. Debug.Log($" Asset: {(uiDoc.visualTreeAsset != null ? uiDoc.visualTreeAsset.name : "NULL")}");
  61. }
  62. }
  63. }