-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
using version 3.4.2 (not unity package)
first relation of an object is DeSerialized as a component? i don't know
using System.IO;
using UnityEngine;
using Friflo.Engine.ECS; //ver 3.4.2
using Friflo.Engine.ECS.Serialize;
public struct RelationA : IRelation<int>
{
public int key;
public int data;
public int GetRelationKey()
{
return key;
}
}
public class RelationTest : MonoBehaviour
{
private void Awake()
{
Test();
}
public void Test()
{
var store = new EntityStore();
var entity1 = store.CreateEntity();
entity1.AddRelation(new RelationA { key = 1, data = 1 });
EntitySerializer ser = new EntitySerializer();
var stream = new MemoryStream();
ser.WriteStore(store, stream);
var store2 = new EntityStore();
ser.ReadIntoStore(store2, stream);
foreach (var e in store.Entities)
{
Debug.Log($"{e.DebugJSON}");
}
foreach (var e in store2.Entities)
{
Debug.Log($"{e.DebugJSON}");
}
}
}Output 1:
{
"id": 1,
"components": {
"RelationA": [{"key":1,"data":1}]
}
}
Output 2:
{
"id": 1,
"components": {
"RelationA": {"key":0,"data":0},
"RelationA": [{"key":1,"data":1}]
}
}
the "duplicated" relation appears in entity.Components but not in entity.GetRelations<RelationA>()
this also deletes one relation if 2 different relation structs are added to the entity
Metadata
Metadata
Assignees
Labels
No labels