| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using UnityEngine;
- using UnityEngine.UIElements;
- public class TestTownShopUI : MonoBehaviour
- {
- public void TestShopUI()
- {
- Debug.Log("Creating test shop UI...");
- var shopUIObject = new GameObject("TestTownShopUI");
- var uiDocument = shopUIObject.AddComponent<UIDocument>();
- // Load the UXML
- uiDocument.visualTreeAsset = Resources.Load<VisualTreeAsset>("UI/TownShopUI");
- if (uiDocument.visualTreeAsset == null)
- {
- Debug.LogError("Failed to load UXML!");
- return;
- }
- Debug.Log("UXML loaded successfully");
- // Get the root and shop container
- var root = uiDocument.rootVisualElement;
- var shopContainer = root?.Q<VisualElement>("shop-container");
- Debug.Log($"Root: {root != null}, ShopContainer: {shopContainer != null}");
- if (shopContainer != null)
- {
- shopContainer.style.display = DisplayStyle.Flex;
- Debug.Log("Shop container made visible");
- // Test setting some content
- var shopName = root.Q<Label>("shop-name");
- if (shopName != null)
- {
- shopName.text = "TEST SHOP";
- Debug.Log("Shop name set");
- }
- }
- }
- }
|