Files
test/Assets/PerfectWorld/Scripts/UI/ShopSystemSetup.cs
T
2025-10-27 09:39:27 +07:00

107 lines
2.6 KiB
C#

using UnityEngine;
public class ShopSystemSetup : MonoBehaviour
{
[Header("Required Components")]
public GShopLoader shopLoader;
public ShopUIManager shopUIManager;
public ShopCategoryManager shopCategoryManager;
[Header("Auto Setup")]
public bool autoFindComponents = true;
void Start()
{
if (autoFindComponents)
{
AutoSetupComponents();
}
ConnectComponents();
}
void AutoSetupComponents()
{
// Find GShopLoader
if (shopLoader == null)
{
shopLoader = FindFirstObjectByType<GShopLoader>();
}
// Find ShopUIManager
if (shopUIManager == null)
{
shopUIManager = FindFirstObjectByType<ShopUIManager>();
}
// Find ShopCategoryManager
if (shopCategoryManager == null)
{
shopCategoryManager = FindFirstObjectByType<ShopCategoryManager>();
}
}
void ConnectComponents()
{
// Connect ShopUIManager with GShopLoader
if (shopUIManager != null && shopLoader != null)
{
shopUIManager.shopLoader = shopLoader;
}
// Connect ShopCategoryManager with ShopUIManager
if (shopCategoryManager != null && shopUIManager != null)
{
shopCategoryManager.Initialize(shopUIManager);
}
Debug.Log("Shop system components connected successfully");
}
[ContextMenu("Test Shop System")]
void TestShopSystem()
{
if (shopUIManager != null)
{
shopUIManager.OpenShop();
Debug.Log("Test: Shop opened");
}
else
{
Debug.LogWarning("ShopUIManager not found for testing");
}
}
[ContextMenu("Validate Setup")]
void ValidateSetup()
{
bool isValid = true;
if (shopLoader == null)
{
Debug.LogError("GShopLoader is missing!");
isValid = false;
}
if (shopUIManager == null)
{
Debug.LogError("ShopUIManager is missing!");
isValid = false;
}
if (shopCategoryManager == null)
{
Debug.LogError("ShopCategoryManager is missing!");
isValid = false;
}
if (isValid)
{
Debug.Log("✓ All shop system components are properly set up!");
}
else
{
Debug.LogError("✗ Shop system setup is incomplete!");
}
}
}