Example #1
0
        static public Entity DeserializeEntity(GameObjectInfo entityInfo)
        {
            var result = new Entity();

            foreach (var comInfo in entityInfo.ComInfoList)
            {
                var com = DeserializeComponent(comInfo);
                result.AddComponent(com);
            }

            foreach (var childInfo in entityInfo.ChildrenList)
            {
                var child = DeserializeEntity(childInfo);
                child.GetComponent <Transform>().parent = result.GetComponent <Transform>();
            }

            return(result);
        }
Example #2
0
        static public GameObjectInfo SerializeEntity(Entity entity)
        {
            var result = new GameObjectInfo();

            foreach (var com in entity.GetAllComponents())
            {
                result.ComInfoList.Add(SerializeComponent(com));
            }

            if (entity.transform != null)
            {
                foreach (var childTransform in entity.transform._children)
                {
                    var child = childTransform.entity;
                    result.ChildrenList.Add(SerializeEntity(child));
                }
            }

            return(result);
        }