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(); 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); } } }