BuildSettingsHelper.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * BUILD SETTINGS SETUP INSTRUCTIONS
  3. * =================================
  4. *
  5. * If your title screen buttons aren't loading scenes, the most likely issue
  6. * is that the scenes aren't properly added to Build Settings.
  7. *
  8. * REQUIRED SCENES IN BUILD SETTINGS:
  9. * =================================
  10. *
  11. * Go to File > Build Settings and ensure these scenes are added IN THIS ORDER:
  12. *
  13. * Index 0: TitleScreenScene (or TitleScreen)
  14. * Index 1: MainTeamSelectScene
  15. * Index 2: BattleSetupMenu
  16. * Index 3: BattleScene
  17. *
  18. * HOW TO ADD SCENES:
  19. * ==================
  20. *
  21. * 1. Open File > Build Settings
  22. * 2. Click "Add Open Scenes" if the current scene isn't listed
  23. * 3. OR drag scene files from Project window into the "Scenes In Build" area
  24. * 4. Make sure the scenes are in the correct order (drag to reorder)
  25. * 5. Make sure all scenes have checkmarks (enabled)
  26. *
  27. * SCENE NAMES MUST MATCH EXACTLY:
  28. * ===============================
  29. *
  30. * The script looks for these exact names:
  31. * - "MainTeamSelectScene" (not "MainTeamSelect" or "TeamSelect")
  32. * - "BattleSetupMenu" (not "BattleSetup")
  33. * - "BattleScene" (not "Battle")
  34. *
  35. * If your scene names are different, either:
  36. * A) Rename your scene files to match, OR
  37. * B) Update the TitleScreenManager script to use your scene names
  38. *
  39. * DEBUGGING SCENE ISSUES:
  40. * ======================
  41. *
  42. * 1. Select the TitleScreenManager GameObject in your scene
  43. * 2. In the Inspector, right-click the component and choose "Check Build Settings"
  44. * 3. Look at the Console for a list of scenes in Build Settings
  45. * 4. Verify "MainTeamSelectScene" appears in the list
  46. *
  47. * LOAD GAME BUTTON ISSUES:
  48. * ========================
  49. *
  50. * The Load Game button will be disabled (grayed out) if:
  51. * - No character data is saved
  52. * - This is the first time running the game
  53. * - Save data was cleared
  54. *
  55. * To test Load Game functionality:
  56. * 1. Click "New Game" first
  57. * 2. Create at least one character in the team select screen
  58. * 3. Return to title screen
  59. * 4. The "Load Game" button should now be enabled
  60. *
  61. * COMMON ISSUES:
  62. * =============
  63. *
  64. * ❌ "Scene 'MainTeamSelectScene' couldn't be loaded"
  65. * → Scene not in Build Settings
  66. *
  67. * ❌ Buttons don't respond to clicks
  68. * → Check Console for "Button not found" warnings
  69. * → Verify UXML button names match script expectations
  70. *
  71. * ❌ Load Game button always disabled
  72. * → No character data saved yet
  73. * → Create characters first with New Game
  74. *
  75. * ❌ Styling issues
  76. * → Ensure USS file is assigned to UIDocument
  77. * → Check for USS syntax errors in Console
  78. *
  79. */
  80. using UnityEngine;
  81. public class BuildSettingsHelper : MonoBehaviour
  82. {
  83. [Header("Build Settings Checker")]
  84. [TextArea(5, 8)]
  85. public string instructions = @"1. Go to File > Build Settings
  86. 2. Add scenes in this order:
  87. - TitleScreenScene (index 0)
  88. - MainTeamSelectScene (index 1)
  89. - BattleSetupMenu (index 2)
  90. - BattleScene (index 3)
  91. 3. Ensure all scenes are enabled (checked)
  92. 4. Use context menu to verify setup";
  93. [ContextMenu("Check Required Scenes")]
  94. public void CheckRequiredScenes()
  95. {
  96. string[] requiredScenes = { "TitleScreenScene", "MainTeamSelectScene", "BattleSetupMenu", "BattleScene" };
  97. Debug.Log("=== CHECKING REQUIRED SCENES ===");
  98. for (int i = 0; i < requiredScenes.Length; i++)
  99. {
  100. bool found = false;
  101. for (int j = 0; j < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; j++)
  102. {
  103. string scenePath = UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(j);
  104. string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePath);
  105. if (sceneName.Equals(requiredScenes[i], System.StringComparison.OrdinalIgnoreCase))
  106. {
  107. Debug.Log($"✓ {requiredScenes[i]} found at index {j}");
  108. found = true;
  109. break;
  110. }
  111. }
  112. if (!found)
  113. {
  114. Debug.LogError($"❌ {requiredScenes[i]} NOT FOUND in Build Settings!");
  115. }
  116. }
  117. Debug.Log("=== CHECK COMPLETE ===");
  118. }
  119. [ContextMenu("List All Build Settings")]
  120. public void ListAllBuildSettings()
  121. {
  122. Debug.Log("=== ALL SCENES IN BUILD SETTINGS ===");
  123. for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; i++)
  124. {
  125. string scenePath = UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(i);
  126. string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePath);
  127. Debug.Log($"Index {i}: {sceneName}");
  128. }
  129. }
  130. }