123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- using KairoEngine.Inventory;
- namespace KairoEngine.CharacterSystem
- {
- public class SerializerWorldItemContainer : MonoBehaviour
- {
- private ItemContainer itemContainer;
- void Start()
- {
- itemContainer = gameObject.GetComponent<ItemContainer>();
- if(itemContainer == null) Debug.LogError("No ItemContainer found for SerializeWorldItemContainer in GameObject " + gameObject.name);
- }
- void OnEnable()
- {
- SerializationEvents.OnSerializeData += Serialize;
- }
- void OnDisable()
- {
- SerializationEvents.OnSerializeData -= Serialize;
- }
- private void Serialize()
- {
- string name = itemContainer.title;
- DataWorldItemContainer dataWorldItemContainer = new DataWorldItemContainer(name, itemContainer.inventory);
- DataManager.instance.currentSceneData.itemContainersData.Add(dataWorldItemContainer);
- }
- }
- }
|