/* * TITLE SCREEN ERROR TROUBLESHOOTING GUIDE * ======================================== * * If you're getting ArgumentOutOfRangeException errors when running the Title Screen, * this is likely due to UI Toolkit stylesheet issues. * * SOLUTION STEPS: * ============== * * 1. REMOVE USS REFERENCE FROM UXML (FIXED) * - The TitleScreen.uxml file now has the problematic Style reference removed * - You'll need to manually assign the USS file in Unity instead * * 2. ASSIGN STYLESHEET MANUALLY IN UNITY: * a) Open your TitleScreen scene * b) Select the GameObject with UIDocument component * c) In the UIDocument component, find the "Style Sheets" section * d) Click the "+" button to add a style sheet * e) Assign the TitleScreen.uss file from Assets/UI Toolkit/ * * 3. ALTERNATIVE SIMPLE SETUP (If USS still causes issues): * - You can remove the USS file entirely and use inline styles * - The buttons will use Unity's default styling * - See the SimpleSetup method below for code-based styling * * 4. VERIFY SETUP: * - Make sure the UXML file is assigned to the UIDocument * - Make sure the TitleScreenManager script is on the same GameObject * - Check Console for any "not found" warnings about buttons * * COMMON ISSUES: * ============= * * - USS files with unsupported CSS properties cause this error * - Hardcoded GUID references in UXML can break when files are moved * - Button names in UXML must match exactly what the script expects * * TEST WITHOUT STYLING: * ==================== * * If you want to test functionality without any styling issues: * 1. Remove the USS file assignment completely * 2. The UI will use Unity's default button styling * 3. Once functionality works, you can re-add styling gradually * */ using UnityEngine; using UnityEngine.UIElements; public class TitleScreenTroubleshooter : MonoBehaviour { [Header("Troubleshooting Options")] public bool useSimpleSetupWithoutUSS = false; [ContextMenu("Apply Simple Setup (No USS)")] public void ApplySimpleSetup() { var uiDocument = GetComponent(); if (uiDocument == null) { Debug.LogError("No UIDocument found on this GameObject"); return; } var root = uiDocument.rootVisualElement; // Apply basic inline styling to avoid USS issues var titleScreen = root.Q("TitleScreen"); if (titleScreen != null) { titleScreen.style.width = Length.Percent(100); titleScreen.style.height = Length.Percent(100); titleScreen.style.backgroundColor = new Color(0.08f, 0.08f, 0.12f, 1f); // Dark blue background } var mainContent = root.Q("MainContent"); if (mainContent != null) { mainContent.style.width = Length.Percent(100); mainContent.style.height = Length.Percent(100); mainContent.style.alignItems = Align.Center; mainContent.style.justifyContent = Justify.Center; mainContent.style.flexDirection = FlexDirection.Column; } var gameTitle = root.Q