127 lines
3.1 KiB
C#
127 lines
3.1 KiB
C#
using UnityEngine;
|
|
|
|
public class ShopSystemSetup : MonoBehaviour
|
|
{
|
|
[Header("Required Components")]
|
|
public GShopLoader shopLoader;
|
|
public ShopUIManager shopUIManager;
|
|
public ShopCategoryManager shopCategoryManager;
|
|
public ShopIconHandler shopIconHandler;
|
|
|
|
[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>();
|
|
}
|
|
|
|
// Find ShopIconHandler
|
|
if (shopIconHandler == null)
|
|
{
|
|
shopIconHandler = FindFirstObjectByType<ShopIconHandler>();
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
// Connect ShopIconHandler with ShopUIManager
|
|
if (shopIconHandler != null && shopUIManager != null)
|
|
{
|
|
shopIconHandler.SetShopManager(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 (shopIconHandler == null)
|
|
{
|
|
Debug.LogError("ShopIconHandler is missing!");
|
|
isValid = false;
|
|
}
|
|
|
|
if (isValid)
|
|
{
|
|
Debug.Log("✓ All shop system components are properly set up!");
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("✗ Shop system setup is incomplete!");
|
|
}
|
|
}
|
|
}
|