using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; using System; // Class to represent character information [System.Serializable] public class CharacterInfo { public string characterName; public string iconName; public string modelName; public int price; public string productID; public bool isUnlocked; } public class StoreManager : MonoBehaviour { public Color selectedColor = new Color(0.953f, 0.811f, 0.180f); // Color for the selected button (converted from hexadecimal) public Color defaultColor = new Color(0.035f, 0.051f, 0.161f); // Default color for unselected buttons (converted from hexadecimal) public Color defaultSelectionBtn_Color = new Color(0.294f, 0.686f, 0.196f); // Default color for unselected buttons (converted from hexadecimal) public Color selectedSelectionBtn_Color = new Color(0.227f, 0.537f, 0.733f); // Default color for unselected buttons (converted from hexadecimal) public GameObject characterSelectionCanvas; // Reference to the Character_Selection canvas public GameObject characterIconPrefab; // Reference to the prefab for character icons [HideInInspector] public List characterList; // List of character information // public GameObject characterSelectionCanvas; // Reference to the Character_Selection canvas // public GameObject topLeftContainerPrefab; // Reference to the prefab to be duplicated // public int numberOfDuplicates = 3; // Number of duplicates to create [SerializeField] private List additionalCharacters; public GameObject buy_popUp; int buy_popUp_active = 0; // Start is called before the first frame update void Start() { // Debug.Log ("Hello B"); GameObject buy_popUp = GameObject.Find("Buy_PopUp"); if (buy_popUp != null){ buy_popUp.SetActive(false); } // Initialize characterList with sample data characterList = new List { new CharacterInfo { characterName = "CAT", iconName = "Cat4X-removebg-preview 2", modelName = "Cat4X-removebg-preview 2", price = 1300, productID = "com.ex.cat", isUnlocked = true }, new CharacterInfo { characterName = "CHEETAH", iconName = "Cheetah5X-removebg-preview 2", modelName = "Cheetah5X-removebg-preview 2", price = 1500, productID = "com.ex.cheetah", isUnlocked = true }, new CharacterInfo { characterName = "EAGLE", iconName = "EagleX-removebg-preview 2",modelName = "EagleX-removebg-preview 2", price = 2000, productID = "com.ex.eagle", isUnlocked = true }, // Add more characters as needed }; // Add characters from the Unity Inspector characterList.AddRange(additionalCharacters); PopulateShopWithCharacters(); } //Add Items to the shop void PopulateShopWithCharacters() { // Debug.Log ("Hello B"); // Check if the canvas and prefab are assigned if (characterSelectionCanvas == null) { // Debug.LogError("Character_Selection canvas is not assigned!"); return; } if (characterIconPrefab == null) { // Debug.LogError("Character Icon prefab is not assigned!"); return; } // Loop through the character list and create icons for each character foreach (CharacterInfo characterInfo in characterList) { // Instantiate the character icon prefab GameObject characterIcon = Instantiate(characterIconPrefab, characterSelectionCanvas.transform); // Access the Button component on the prefab Button iconButton = characterIcon.GetComponent