IEnumerator LoadDelay()
        {
            yield return(0);

            Q_Inventory            playerInventory        = Q_GameMaster.Instance.inventoryManager.playerInventory;
            PlayerInventoryManager playerInventoryManager = Q_GameMaster.Instance.inventoryManager.playerInventoryManager;
            InventorySaveData      saveData           = Q_GameMaster.Instance.inventoryManager.itemDataBase.saveData;
            GameObject             equipmentContainer = Q_GameMaster.Instance.inventoryManager.m_EquipmentContainer;

            foreach (var item in saveData.playerInventoryItems)
            {
                for (int i = 0; i < item.amount; i++)
                {
                    playerInventory.AddItem(item.item.ID);
                }
            }

            for (int i = 0; i < saveData.playerAttributes.Count; i++)
            {
                playerInventoryManager.playerAttributes[i].currentValue = saveData.playerAttributes[i].currentValue;
                playerInventoryManager.playerAttributes[i].minValue     = saveData.playerAttributes[i].minValue;
                playerInventoryManager.playerAttributes[i].maxValue     = saveData.playerAttributes[i].maxValue;
            }

            for (int i = 0; i < saveData.playerCurrencies.Count; i++)
            {
                playerInventoryManager.playerCurrencies[i].amount = saveData.playerCurrencies[i].amount;
            }

            for (int i = 0; i < saveData.onEquipmentItems.Count; i++)
            {
                playerInventory.AddItem(saveData.onEquipmentItems[i]).WearEquipmentItemWithoutChangeAttribute();
            }
        }
        public static InventorySaveData Create()
        {
            InventorySaveData asset = ScriptableObject.CreateInstance <InventorySaveData>();

            AssetDatabase.CreateAsset(asset, EditorPrefs.GetString("DatabasePath") + "/Save/Saving.asset");
            AssetDatabase.SaveAssets();
            return(asset);
        }
        public static void ClearInventoryData()
        {
            InventorySaveData m_SaveData = Q_GameMaster.Instance.inventoryManager.itemDataBase.saveData;

            m_SaveData.playerInventoryItems.Clear();
            m_SaveData.playerAttributes.Clear();
            m_SaveData.playerCurrencies.Clear();
            m_SaveData.onEquipmentItems.Clear();
            Debug.Log("Successfully Clear Inventory Data");
        }
        public static void SaveInventoryData()
        {
            Q_Inventory       m_PlayerInventory = Q_GameMaster.Instance.inventoryManager.playerInventory;
            InventorySaveData m_SaveData        = Q_GameMaster.Instance.inventoryManager.itemDataBase.saveData;
            List <Item>       items             = m_PlayerInventory.items;
            List <GameObject> slots             = m_PlayerInventory.slots;

            m_SaveData.playerInventoryItems.Clear();

            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].ID != -1)
                {
                    int amount = slots[i].transform.GetChild(0).GetComponent <ItemData>().amount;
                    m_SaveData.playerInventoryItems.Add(new ItemToSave(items[i], amount));
                }
            }

            List <PlayerCurrency> playerCurrencies = Q_GameMaster.Instance.inventoryManager.playerInventoryManager.playerCurrencies;

            m_SaveData.playerCurrencies.Clear();
            for (int i = 0; i < playerCurrencies.Count; i++)
            {
                m_SaveData.playerCurrencies.Add(new CurrencyToSave(playerCurrencies[i].currency, playerCurrencies[i].amount));
            }

            List <PlayerAttribute> playerAttributes = Q_GameMaster.Instance.inventoryManager.playerInventoryManager.playerAttributes;

            m_SaveData.playerAttributes.Clear();
            for (int i = 0; i < playerAttributes.Count; i++)
            {
                m_SaveData.playerAttributes.Add(new PlayerAttribute(playerAttributes[i].playerAttribute, playerAttributes[i].currentValue, playerAttributes[i].minValue, playerAttributes[i].maxValue));
            }

            m_SaveData.onEquipmentItems.Clear();
            GameObject equipmentContainer = Q_GameMaster.Instance.inventoryManager.m_EquipmentContainer;

            for (int i = 0; i < equipmentContainer.transform.childCount; i++)
            {
                if (equipmentContainer.transform.GetChild(i).childCount == 2)
                {
                    ItemData data = equipmentContainer.transform.GetChild(i).GetChild(1).GetComponent <ItemData>();
                    m_SaveData.onEquipmentItems.Add(data.item.ID);
                }
            }


            Debug.Log("Successfully Save Inventory Data");
        }
        public void Load()
        {
            //Player
            Q_Inventory            playerInventory        = Q_GameMaster.Instance.inventoryManager.playerInventory;
            PlayerInventoryManager playerInventoryManager = Q_GameMaster.Instance.inventoryManager.playerInventoryManager;
            InventorySaveData      saveData           = Q_GameMaster.Instance.inventoryManager.itemDataBase.saveData;
            GameObject             equipmentContainer = Q_GameMaster.Instance.inventoryManager.m_EquipmentContainer;

            for (int i = 0; i < equipmentContainer.transform.childCount; i++)
            {
                if (equipmentContainer.transform.GetChild(i).childCount == 2)
                {
                    ItemData data = equipmentContainer.transform.GetChild(i).GetChild(1).GetComponent <ItemData>();
                    data.UnwearItemWithoutAdd();
                }
            }

            playerInventory.ClearAllItems();

            StartCoroutine(LoadDelay());
        }