Ejemplo n.º 1
0
        /// <summary>
        /// Saves the given models and potentially all models referenced by the given models into modelBlobs.
        /// </summary>
        /// <param name="models">The models that will be saved, potentially along with the models they have references to.</param>
        /// <param name="saveReferenced">Whether the given models should also save their referenced models.</param>
        /// <returns>All models in form of modelBlobs, xml formatted strings order by id.</returns>
        public static ModelBlobs Save(List <Model> models, bool saveReferenced)
        {
            if (models == null)
            {
                UnityEngine.Debug.LogError("Can't save Models if the given list is null");
                return(null);
            }
            models.Distinct <Model>();
            if (saveReferenced)
            {
                foreach (Model model in models)
                {
                    models.AddList <Model>(model.GetReferences());
                }
            }
            models.Distinct <Model>();
            ModelBlobs modelBlobs = new ModelBlobs();

            modelBlobs.Add("manifest", Manifest.Save(models));
            isSerializing = true;
            foreach (Model model in models)
            {
                modelBlobs.Add(model.Id, model.XmlSerializeToString());
            }
            isSerializing = false;
            return(modelBlobs);
        }
Ejemplo n.º 2
0
        private static ModelBlobs FromStringArray(string[] splittedData)
        {
            ModelBlobs modelBlobs = new ModelBlobs();
            string     id         = null;

            foreach (string blob in splittedData)
            {
                if (string.IsNullOrEmpty(id))
                {
                    id = blob;
                }
                else
                {
                    modelBlobs.Add(id, blob);
                    id = null;
                }
            }
            return(modelBlobs);
        }