Пример #1
0
        public bool OpenDeserialize(byte[] bytes)
        {
            readerSettings = new JsonReaderSettings();
            readerSettings.AddTypeConverter(new VectorConverter());
            readerSettings.AddTypeConverter(new BoundsConverter());
            readerSettings.AddTypeConverter(new LayerMaskConverter());
            readerSettings.AddTypeConverter(new MatrixConverter());
            readerSettings.AddTypeConverter(new GuidConverter());
            readerSettings.AddTypeConverter(new UnityObjectConverter());

            str = new MemoryStream();
            str.Write(bytes, 0, bytes.Length);
            str.Position = 0;
            try {
                zip = ZipFile.Read(str);
            } catch (ZipException e) {
                //Catches exceptions when an invalid zip file is found
                Debug.LogWarning("Caught exception when loading from zip\n" + e);
                str.Close();
                return(false);
            }
            meta = DeserializeMeta(zip["meta" + jsonExt]);

            if (meta.version > AstarPath.Version)
            {
                Debug.LogWarning("Trying to load data from a newer version of the A* Pathfinding Project\nCurrent version: " + AstarPath.Version + " Data version: " + meta.version);
            }
            else if (meta.version < AstarPath.Version)
            {
                Debug.LogWarning("Trying to load data from an older version of the A* Pathfinding Project\nCurrent version: " + AstarPath.Version + " Data version: " + meta.version);
            }
            return(true);
        }
		public void OpenSerialize () {
			zip = new ZipFile();
			zip.AlternateEncoding = System.Text.Encoding.UTF8;
			zip.AlternateEncodingUsage = ZipOption.Always;
			
			writerSettings = new JsonWriterSettings();
			writerSettings.AddTypeConverter (new VectorConverter());
			writerSettings.AddTypeConverter (new BoundsConverter());
			writerSettings.AddTypeConverter (new LayerMaskConverter());
			writerSettings.AddTypeConverter (new MatrixConverter());
			writerSettings.AddTypeConverter (new GuidConverter());
			writerSettings.AddTypeConverter (new UnityObjectConverter());
			
			//writerSettings.DebugMode = true;
			writerSettings.PrettyPrint = settings.prettyPrint;
			
			meta = new GraphMeta();
		}
Пример #3
0
        public void OpenSerialize()
        {
            zip = new ZipFile();
            zip.AlternateEncoding      = System.Text.Encoding.UTF8;
            zip.AlternateEncodingUsage = ZipOption.Always;

            writerSettings = new JsonWriterSettings();
            writerSettings.AddTypeConverter(new VectorConverter());
            writerSettings.AddTypeConverter(new BoundsConverter());
            writerSettings.AddTypeConverter(new LayerMaskConverter());
            writerSettings.AddTypeConverter(new MatrixConverter());
            writerSettings.AddTypeConverter(new GuidConverter());
            writerSettings.AddTypeConverter(new UnityObjectConverter());

            //writerSettings.DebugMode = true;
            writerSettings.PrettyPrint = settings.prettyPrint;

            meta = new GraphMeta();
        }
Пример #4
0
        public bool OpenDeserialize(byte[] bytes)
        {
            readerSettings = new JsonReaderSettings();
            readerSettings.AddTypeConverter (new VectorConverter());
            readerSettings.AddTypeConverter (new BoundsConverter());
            readerSettings.AddTypeConverter (new LayerMaskConverter());
            readerSettings.AddTypeConverter (new MatrixConverter());
            readerSettings.AddTypeConverter (new GuidConverter());
            readerSettings.AddTypeConverter (new UnityObjectConverter());

            str = new MemoryStream();
            str.Write(bytes,0,bytes.Length);
            str.Position = 0;
            try {
                zip = ZipFile.Read(str);
            } catch (ZipException e) {
                //Catches exceptions when an invalid zip file is found
                Debug.LogWarning ("Caught exception when loading from zip\n"+e);
                str.Close();
                return false;
            }
            meta = DeserializeMeta (zip["meta"+jsonExt]);

            if (meta.version > AstarPath.Version) {
                Debug.LogWarning ("Trying to load data from a newer version of the A* Pathfinding Project\nCurrent version: "+AstarPath.Version+" Data version: "+meta.version);
            } else if (meta.version < AstarPath.Version) {
                Debug.LogWarning ("Trying to load data from an older version of the A* Pathfinding Project\nCurrent version: "+AstarPath.Version+" Data version: "+meta.version);
            }
            return true;
        }