using UnityEngine; public class PrefabManager : MonoBehaviour { public static PrefabManager Instance; public GameObject slotPrefab; public GameObject itemPrefab; public GameObject hotkeyEntryPrefab; public GameObject tilePrefab; public GameObject cropPrefab; public Object interactablePrefab; public GameObject[] cropPrefabs; public GameObject[] treePrefabs; public GameObject[] rockPrefabs; public GameObject[] boxPrefabs; public GameObject[] bushPrefabs; private void Awake() { Debug.Log("PrefabManager Awake"); if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); LoadCropPrefabs(); } else { Destroy(gameObject); } } private void LoadCropPrefabs() { cropPrefabs = Resources.LoadAll("Prefabs/Interactable/Crops"); Debug.Log("Loaded " + cropPrefabs.Length + " crop prefabs"); } public GameObject GetSlotPrefab() { Debug.Log("Getting Slot Pefab"); if (slotPrefab == null) Debug.LogWarning("SlotPrefab is null"); return slotPrefab; } public GameObject GetHotkeyEntryPrefab() { Debug.Log("Getting HotkeyEntry Pefab"); if (hotkeyEntryPrefab == null) Debug.LogWarning("HotkeyEntryPrefab is null"); return hotkeyEntryPrefab; } public GameObject GetItemPrefab() { return itemPrefab; } public GameObject GetTilePrefab() { return tilePrefab; } public GameObject GetCropPrefab() { return cropPrefab; } public Object GetInteractablePrefab() { return interactablePrefab; } public GameObject GetRandomCropPrefabInstance() { var randomIndex = Random.Range(0, cropPrefabs.Length - 1); var crop = Instantiate(cropPrefabs[randomIndex]); // get new var cropInteractable = crop.GetComponent(); cropInteractable.Initialize(); Debug.Log("Crop Prefab Instance initialized"); return crop; } }